home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Aktief 1995 #6 / CDA_6.iso / shell / utils / disked29.arj / SOURCE.ZIP / ALLOC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-19  |  3.3 KB  |  130 lines

  1. /***
  2. *alloc.h - disked definitions/declarations for malloc shell.
  3. *
  4. *Copyright (c) 1993-1995, Gregg Jennings.  All wrongs reserved.
  5. *   P O Box 200, Falmouth, MA 02541-0200
  6. *
  7. *Purpose:
  8. *   See ALLOC.C
  9. *
  10. *Notice:
  11. *   This progam may be freely used and distributed.  Any distrubution
  12. *   with modifications must retain the above copyright statement and
  13. *   modifications noted.
  14. *   No pulp-publication, in whole or in part, permitted without
  15. *   permission (magazines or books).
  16. *******************************************************************************/
  17.  
  18. /*
  19.    Version
  20.  
  21.    2.3 24-Jul-1994   added memavailable stuff
  22.    2.1 25-Jul-1994   added gloabl for mem testing
  23.    2.0 28-Nov-1993
  24.  
  25.    Usage:
  26.  
  27.    see ALLOC.C
  28.  
  29. */
  30.  
  31.  
  32. #ifdef _MSC_VER
  33.  
  34.  #if (_MSC_VER <= 600)
  35.   #define _halloc    halloc
  36.   #define _hfree     hfree
  37.  #endif
  38.  
  39.  #define huge_alloc(n,s)   _halloc(n,(size_t)s)
  40.  #define huge_free         _hfree
  41.  #define memavail()        ((unsigned long)_memavl())
  42.  
  43. #endif
  44.  
  45. #if defined(__BORLANDC__) || defined(__TURBOC__)   
  46.  
  47.  #define _memmax     coreleft
  48.  #define _fheapset   _heapset
  49.  #define _heapset    heapfillfree
  50.  #define _heapinfo   heapinfo
  51.  #define _heapwalk   farheapwalk
  52.  #define _nheapwalk  heapwalk
  53.  #define _fheapchk   farheapcheck
  54.  #define _heapchk    farheapcheck
  55.  #define _nheapchk   heapcheck
  56.  #define _pentry     ptr
  57.  #define _size       size
  58.  #define _useflag    in_use
  59.  
  60.  #define huge_alloc  farcalloc
  61.  #define huge_free   farfree
  62.  #define memavail    coreleft
  63.  
  64. #endif
  65.  
  66. #ifdef __WATCOMC__
  67.  
  68.  #define huge_alloc(n,s)   halloc(n,(size_t)s)
  69.  #define huge_free         hfree 
  70.  #define memavail()        ((unsigned long)_memavl())
  71.  
  72. #endif
  73.  
  74. extern void (*alloc_handler)(void);
  75. extern void set_alloc_handler(void (*func)(void));
  76. extern void *alloc(size_t num, size_t size);
  77. extern void _near *nalloc(size_t num, size_t size);
  78. extern void *newalloc(void *p, size_t size);
  79. extern void _huge *hugealloc(long num, long size);
  80. extern void  freep(void *addr);
  81. extern void  nfreep(void _near *addr);
  82. extern void  hugefreep(void _huge *addr);
  83. extern char *heapstat(int status);
  84. extern int   heaptest(void);
  85.  
  86. /*
  87.    Constants for _heapchk/_heapset/_heapwalk routines
  88.    as defined in compiler's MALLOC.H: (for reference
  89.    only)
  90.  
  91. Borland:
  92.  
  93. #define _HEAPEMPTY      1     // 0
  94. #define _HEAPOK         2     // 1
  95. #define _HEAPEND        5     // 4
  96. #define _HEAPCORRUPT   -1     // 5
  97. #define _BADNODE       -2     // 2
  98. #define _BADVALUE      -3     // 3
  99.  
  100. #define _FREEENTRY      3
  101. #define _USEDENTRY      4
  102.  
  103. Microsoft:
  104.  
  105. #define _HEAPEMPTY      (-1)
  106. #define _HEAPOK         (-2)           // _heapchk/_heapset only
  107. #define _HEAPBADBEGIN   (-3)
  108. #define _HEAPBADNODE    (-4)
  109. #define _HEAPEND        (-5)           // _heapwalk only
  110. #define _HEAPBADPTR     (-6)
  111.  
  112. #define _FREEENTRY      0
  113. #define _USEDENTRY      1
  114.  
  115. Watcom:
  116.  
  117. #define _HEAPOK         0
  118. #define _HEAPEMPTY      1  // heap isn't initialized
  119. #define _HEAPBADBEGIN   2  // heap header is corrupted
  120. #define _HEAPBADNODE    3  // heap entry is corrupted
  121. #define _HEAPEND        4  // end of heap entries (_heapwalk)
  122. #define _HEAPBADPTR     5  // invalid heap entry pointer (_heapwalk)
  123.  
  124. #define _FREEENTRY      1
  125. #define _USEDENTRY      0
  126.  
  127.  
  128. You can see the dificulty with these compiler library functions!
  129. */
  130.