Listing 1

/* Header for memory blocks */
typedef struct MEMBLOCK {
   struct MEMBLOCK  *mb_next,   /* Pointer to next block */
                 *mb_pres;   /* Present block */
              int  mb_size,   /* Size of blocks */
                  mb_offs;   /* Present offset in block */
} MemBlock;

unsigned int iniz_borrow(), deiniz_borrow(), return_borrow();
char *borrow();

/* ------------------------------------------------------- */

/* Initialise memory */

/* Returns the memory ID or zero on error */

unsigned int iniz_borrow(block)
register int block;              /* Allocation block size */
{
   register MemBlock *p;        /* Pointer to block */

   /* Get first block */
   if((int)(p=(MemBlock *)allocate(block))==0)
      return(0);
   p->mb_next=NULL;               /* No next block */
   p->mb_pres=p;                  /* This is the present block */
   p->mb_size=block;              /* Record the block size */
   p->mb_offs=sizeof(MemBlock);   /* Start past this info */

   return((unsigned int)p);
}