home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 May / VPR9705A.ISO / VPR_DATA / PROGRAM / CBTRIAL / SETUP / DATA.Z / ALLOC.H < prev    next >
C/C++ Source or Header  |  1997-02-14  |  5KB  |  244 lines

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