free.c

来自「上课老师给的8086仿真器」· C语言 代码 · 共 38 行

C
38
字号
/***********************************************************************/
/*  This file is part of the C51 Compiler package                      */
/*  Copyright KEIL ELEKTRONIK GmbH 1993                                */
/***********************************************************************/
/*                                                                     */
/*  FREE.C:                                                            */
/*                                                                     */
/*  To translate this file use C51 with the following invocation:      */
/*                                                                     */
/*     C51 FREE.C  <memory model>                                      */
/*                                                                     */
/*  To link the modified FREE.OBJ file to your application use the     */
/*  following L51 invocation:                                          */
/*                                                                     */
/*     L51 <your object file list>, FREE.OBJ <controls>                */
/*                                                                     */
/***********************************************************************/

struct mem  {
  struct mem xdata *next;
  struct mem xdata *prev;
  unsigned int       len;
  unsigned char      mem[1];
};

void free (struct mem xdata *p)  {
  struct mem xdata *op;

  if (!p) return;
  p = (void xdata *) p - (sizeof (struct mem) - 1);
  if (op = p->prev)  {
    op->next = p->next;
    if (p->next)  p->next->prev = op;
  }
  else p->len = 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?