home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / tua / part01 / mem.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-23  |  1.3 KB  |  58 lines

  1. /**
  2. *** Name ...... :    mem.h
  3. *** Purpose ... :    Fixed blocks allocation
  4. *** Author ....    :    ...sigh! I lost it!
  5. *** Note ...... :    from "The C User Journal"
  6. *** Rcs_id .... :    $Id: mem.h,v 3.3 1991/09/01 14:02:14 piggy Rel $
  7. **/
  8.  
  9. /*
  10.  * Use:
  11.  *    Initialize a FlistHead struct with
  12.  *        MemInit(&StructName, dimension, firstalloc, succalloc)
  13.  *
  14.  *    where firstalloc is the number of objects initially allocated,
  15.  * succalloc is the number of objects to allocate whenever you fill
  16.  * the current space.
  17.  *
  18.  *      With new(&StructName) you get a pointer to a new object.
  19.  *
  20.  *    With delete(&NomeStruct, object) you destroy that object from
  21.  * the list, freeing space for the next allocations.
  22.  *
  23.  */
  24.  
  25. #if defined(M_I286)        /* Per un difetto, il compilatore 286 non */
  26. #define    VOID    char        /* accetta 'void *' */
  27. #else
  28. #define    VOID    void
  29. #endif
  30.  
  31. union freelist
  32. {
  33.     union freelist *next;
  34.     char            memory;
  35.     int             align;
  36. };
  37.  
  38. typedef struct
  39. {
  40.     int             size;
  41.     int             bytes;
  42.     union freelist *freelist;
  43. }               FlistHead;
  44.  
  45. #if defined(__STDC__) && !defined (NO_PROTOTYPE)
  46. VOID           *new(FlistHead *);
  47. void            delete(FlistHead *, void *);
  48. void            MemInit(FlistHead *, int, int, int);
  49.  
  50. #else
  51.  
  52. VOID           *new();
  53. void            delete();
  54. void            MemInit();
  55.  
  56. #endif
  57.  
  58.