home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / INC.PAK / ALLOC.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  5KB  |  242 lines

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