home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / comm / cyberpager-1.5.lha / CyberPager / source / include / memory.h < prev    next >
C/C++ Source or Header  |  1993-06-20  |  740b  |  39 lines

  1.  /*
  2.   * these routines will use pooled memory under V39 or higher or standard
  3.   * memory routines when running under earlier versions of the OS.  We lock
  4.   * semaphores as a means to prevent multiple people from stomping on the
  5.   * pool handles concurrently.
  6.   */
  7.  
  8. extern APTR pool;
  9.  
  10. static void *__inline MyAllocVec(ULONG size)
  11. {
  12.     UBYTE *memory;
  13.  
  14.     size += sizeof(ULONG);
  15.  
  16.     memory = AllocPooled(pool, size);
  17.  
  18.     if (!memory)
  19.         return NULL;
  20.  
  21.     *((ULONG *) memory) = size;
  22.  
  23.     return (void *)(memory + sizeof(ULONG));
  24. }
  25.  
  26. static void __inline MyFreeVec(void *memory)
  27. {
  28.     void *realMemory;
  29.     ULONG size;
  30.  
  31.     if (!memory)
  32.         return;
  33.  
  34.     realMemory = (UBYTE *) memory - sizeof(ULONG);
  35.     size = *((ULONG *) realMemory);
  36.  
  37.     FreePooled(pool, realMemory, size);
  38. }
  39.