Contents    Page-10    Prev    Next    Page+10    Index   

Heap Memory Management


void * new(size)
  long size;
  { CONS * tmp;
    if ( free[size] )
      { tmp = (CONS *) free[size];
        free[size] = tmp->car;
        return (tmp); }
    else if ( (void *) ( (int) nextfree + size)
                                 < maxfree )
      { tmp = nextfree;
        nextfree = (void *)
                   ( (int) nextfree + size);
        return (tmp); }
    else error("Out of Memory");
  }

release(block, size)
  void * block; long size;
  {  ((CONS *) block)->car = free[size];
     free[size] = block;
   }