home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / progs / CB / DATA.Z / ALLOC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-18  |  5.1 KB  |  238 lines

  1. /*  alloc.h
  2.  
  3.     memory management functions and variables.
  4.  
  5. */
  6.  
  7. /* $Copyright: 1987$ */
  8. /* $Revision:   8.1  $ */
  9.  
  10. #if !defined(__ALLOC_H)
  11. #define __ALLOC_H
  12.  
  13. #if !defined(___DEFS_H)
  14. #include <_defs.h>
  15. #endif
  16.  
  17. #ifndef NULL
  18. #include <_null.h>
  19. #endif
  20.  
  21.  
  22. #if !defined(RC_INVOKED)
  23.  
  24. #if defined(__STDC__)
  25. #pragma warn -nak
  26. #endif
  27.  
  28. #endif  /* !RC_INVOKED */
  29.  
  30.  
  31. #if !defined(__FLAT__)
  32.  
  33. #define _HEAPEMPTY      1
  34. #define _HEAPOK         2
  35. #define _FREEENTRY      3
  36. #define _USEDENTRY      4
  37. #define _HEAPEND        5
  38. #define _HEAPCORRUPT    -1
  39. #define _BADNODE        -2
  40. #define _BADVALUE       -3
  41.  
  42. #ifndef _STDDEF
  43. #define _STDDEF
  44. #ifndef _PTRDIFF_T
  45. #define _PTRDIFF_T
  46. #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
  47.   typedef long  ptrdiff_t;
  48. #else
  49.   typedef int ptrdiff_t;
  50. #endif
  51. #endif
  52. #ifndef _SIZE_T
  53.   #define _SIZE_T
  54.   typedef unsigned size_t;
  55. #endif
  56. #endif
  57.  
  58. #if !defined(_Windows)
  59.  
  60. #if !defined(__STDC__)  /* NON_ANSI */
  61. struct farheapinfo
  62.   {
  63.   void huge *ptr;
  64.   unsigned long size;
  65.   int in_use;
  66.   };
  67. #endif
  68.  
  69. #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  70. struct heapinfo
  71.   {
  72.   void _FAR *ptr;
  73.   unsigned int size;
  74.   int in_use;
  75.   };
  76. #else
  77. #define heapinfo farheapinfo
  78. #endif
  79.  
  80. #endif  /* WINDOWS */
  81.  
  82. #ifdef __cplusplus
  83. extern "C" {
  84. #endif
  85.  
  86. void  _FAR *_RTLENTRY calloc(size_t __nitems, size_t __size);
  87. void        _RTLENTRY free(void _FAR *__block);
  88. void  _FAR *_RTLENTRY malloc(size_t __size);
  89. void  _FAR *_RTLENTRY realloc(void _FAR *__block, size_t __size);
  90.  
  91. #if !defined(_Windows)
  92. #if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
  93. unsigned long _RTLENTRY coreleft (void);
  94. #else
  95. unsigned      _RTLENTRY coreleft(void);
  96. #endif
  97. #endif
  98.  
  99. #if defined(__DPMI16__) || !defined(_Windows)
  100. int           _RTLENTRY heapcheck(void);
  101. unsigned long _RTLENTRY farcoreleft(void);
  102. #endif
  103.  
  104. #if defined(__DPMI16__)
  105. #define farheapcheck heapcheck
  106. #define coreleft     farcoreleft
  107. #endif
  108.  
  109. #if !defined(_Windows)
  110.  
  111. int         _RTLENTRY brk(void *__addr);
  112. void       *_RTLENTRY sbrk(int __incr);
  113.  
  114. int         _RTLENTRY heapfillfree(unsigned int __fillvalue);
  115. int         _RTLENTRY heapcheckfree(unsigned int __fillvalue);
  116.  
  117. #if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
  118.  
  119. #if !defined(__STDC__)  /* NON_ANSI */
  120. int         _RTLENTRY heapchecknode(void far *__node);
  121. int         _RTLENTRY heapwalk(struct farheapinfo far *__hi);
  122. #endif
  123.  
  124. #else
  125.  
  126. int         _RTLENTRY heapchecknode(void *__node);
  127. int         _RTLENTRY heapwalk(struct heapinfo *__hi);
  128.  
  129. #endif
  130.  
  131. #if !defined(__STDC__)  /* NON_ANSI */
  132. unsigned long _RTLENTRY farcoreleft(void);
  133. int         _RTLENTRY farheapcheck(void);
  134. int         _RTLENTRY farheapchecknode(void far *__node);
  135. int         _RTLENTRY farheapfillfree(unsigned int __fillvalue);
  136. int         _RTLENTRY farheapcheckfree(unsigned int __fillvalue);
  137. int         _RTLENTRY farheapwalk(struct farheapinfo *__hi);
  138. #endif
  139.  
  140. #endif  /* WINDOWS */
  141.  
  142. #if !defined(__STDC__)  /* NON_ANSI */
  143. void far  * _RTLENTRY farcalloc(unsigned long __nunits, unsigned long __unitsz);
  144. void        _RTLENTRY farfree(void far *__block);
  145. void far  * _RTLENTRY farmalloc(unsigned long __nbytes);
  146. void far  * _RTLENTRY farrealloc(void far *__oldblock, unsigned long __nbytes);
  147. #endif
  148.  
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152.  
  153.  
  154. #else  /* defined __FLAT__ */
  155.  
  156.  
  157. #ifndef _STDDEF
  158. #  define _STDDEF
  159. #  ifndef _PTRDIFF_T
  160. #    define _PTRDIFF_T
  161.      typedef int ptrdiff_t;
  162. #  endif
  163. #  ifndef _SIZE_T
  164. #    define _SIZE_T
  165.      typedef unsigned size_t;
  166. #  endif
  167. #endif
  168.  
  169. #if !defined(__STDC__)
  170. struct heapinfo
  171. {
  172.   void *    ptr;
  173.   void *    ptr2;
  174.   unsigned  size;
  175.   int       in_use;
  176. };
  177. #endif
  178.  
  179. #ifdef __cplusplus
  180. extern "C" {
  181. #endif
  182.  
  183. void *   _RTLENTRY _EXPFUNC calloc(size_t __nitems, size_t __size);
  184. void     _RTLENTRY _EXPFUNC free(void * __block);
  185. void *   _RTLENTRY _EXPFUNC malloc(size_t  __size);
  186. void *   _RTLENTRY _EXPFUNC realloc(void * __block, size_t __size);
  187. int      _RTLENTRY _EXPFUNC heapcheck(void);
  188. int      _RTLENTRY _EXPFUNC heapfillfree(unsigned int __fillvalue);
  189. int      _RTLENTRY _EXPFUNC heapcheckfree(unsigned int __fillvalue);
  190. int      _RTLENTRY _EXPFUNC heapchecknode(void *__node);
  191. int      _RTLENTRY _EXPFUNC heapwalk(struct heapinfo *__hi);
  192.  
  193. #if defined(__DPMI32__)
  194. unsigned _RTLENTRY          coreleft(void);
  195. #endif
  196.  
  197. #ifdef __cplusplus
  198. }
  199. #endif
  200.  
  201. /* Values returned by heap??? and _heap??? functions */
  202.  
  203. #define _HEAPEMPTY      1
  204. #define _HEAPOK         2
  205. #define _FREEENTRY      3
  206. #define _USEDENTRY      4
  207. #define _HEAPEND        5
  208. #define _HEAPCORRUPT    -1
  209. #define _BADNODE        -2
  210. #define _BADVALUE       -3
  211. #define _HEAPBADBEGIN   -4
  212. #define _HEAPBADNODE    -5
  213. #define _HEAPBADPTR     -6
  214.  
  215. #if !defined(__STDC__)
  216. #define farcalloc   calloc
  217. #define farcoreleft coreleft
  218. #define farfree     free
  219. #define farmalloc   malloc
  220. #define farrealloc  realloc
  221. #endif
  222.  
  223. #endif  /* __FLAT__ */
  224.  
  225.  
  226. #if !defined(RC_INVOKED)
  227.  
  228. #if defined(__STDC__)
  229. #pragma warn .nak
  230. #endif
  231.  
  232. #endif  /* !RC_INVOKED */
  233.  
  234.  
  235. #endif  /* __ALLOC_H */
  236.  
  237.  
  238.