home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_04 / 8n04104a < prev    next >
Text File  |  1990-03-20  |  1KB  |  40 lines

  1.  
  2. Listing 1
  3. =========
  4.  
  5. /* Header for memory blocks */
  6. typedef struct MEMBLOCK {
  7.    struct MEMBLOCK   *mb_next,   /* Pointer to next block */
  8.                      *mb_pres;   /* Present block */
  9.                 int   mb_size,   /* Size of blocks */
  10.                       mb_offs;   /* Present offset in block */
  11. } MemBlock;
  12.  
  13. unsigned int iniz_borrow(), deiniz_borrow(), return_borrow();
  14. char *borrow();
  15.  
  16.  
  17. /* -------------------------------------------------------- */
  18.  
  19. /* Initialise memory */
  20.  
  21. /* Returns the memory ID or zero on error */
  22.  
  23. unsigned int iniz_borrow(block)
  24. register int block;              /* Allocation block size */
  25. {
  26.    register MemBlock *p;         /* Pointer to block */
  27.  
  28.    /* Get first block */
  29.    if((int)(p=(MemBlock *)allocate(block))==0) 
  30.       return(0);
  31.    p->mb_next=NULL;              /* No next block */
  32.    p->mb_pres=p;                 /* This is the present block */
  33.    p->mb_size=block;             /* Record the block size */
  34.    p->mb_offs=sizeof(MemBlock);  /* Start past this info */
  35.  
  36.    return((unsigned int)p);
  37. }
  38.  
  39.  
  40.