home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / Level 0 Macintosh 29Sep94 / MyMalloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  1.9 KB  |  54 lines  |  [TEXT/KAHL]

  1. /* MyMalloc.h */
  2.  
  3. #ifndef Included_MyMalloc_h
  4. #define Included_MyMalloc_h
  5.  
  6. /* This module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11.  
  12. /* initialize the memory allocator. */
  13. MyBoolean        InitializeMyMalloc(void);
  14.  
  15. /* allocate a new block of memory.  If there is no free block large enough, the */
  16. /* heap is extended.  If the block size is greater than MINMORECORESIZE, then */
  17. /* a system block the size of the block will be allocated, otherwise a system */
  18. /* block of MINMORECORESIZE bytes will be allocated. */
  19. void*                BlockNew(long RequestedBlockSize);
  20.  
  21. /* this routine releases blocks back to the free list and unifies them with */
  22. /* adjacent blocks if possible.  It keeps the free list in ascending */
  23. /* sorted order to make scanning for adjacent blocks more efficient. */
  24. void                BlockRelease(void* Block);
  25.  
  26. /* decode and return the size of an allocated block */
  27. long                BlockSize(void* Block);
  28.  
  29. /* resize the block.  Minimum of the new size and the old size bytes of data will */
  30. /* be preserved.  NOTE:  The block's address may change!!! */
  31. /* this is a very naive implementation which simply allocates a new block, copies */
  32. /* over all the data, and releases the old block.  This really needs to be improved. */
  33. void*                BlockResize(void* Block, long NewRequestedBlockSize);
  34.  
  35. /* scan list and look for inconsistencies, such as overlapping blocks, blocks */
  36. /* outside of the range of the heap, misaligned blocks, and other weirdness */
  37. /* this routine only does something when debugging is enabled */
  38. #if DEBUG
  39.     void                CheckHeap(void);
  40. #else
  41.     #define CheckHeap()
  42. #endif
  43.  
  44. /* this routine dumps a file to the working directory containing a list of the */
  45. /* free blocks in the heap so that fragmentation performance can be analyzed */
  46. /* this routine only does something when debugging is enabled */
  47. #if DEBUG
  48.     void                CheckFragmentation(void);
  49. #else
  50.     #define CheckFragmentation()
  51. #endif
  52.  
  53. #endif
  54.