home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 14.ddi / GENINC.PAK / ALLOC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  4.3 KB  |  197 lines

  1. /*  alloc.h
  2.  
  3.     memory management functions and variables.
  4.     
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 6.0
  9.  *
  10.  *      Copyright (c) 1987, 1993 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. #if !defined(__FLAT__)
  27.  
  28. #define _HEAPEMPTY      1
  29. #define _HEAPOK         2
  30. #define _FREEENTRY      3
  31. #define _USEDENTRY      4
  32. #define _HEAPEND        5
  33. #define _HEAPCORRUPT    -1
  34. #define _BADNODE        -2
  35. #define _BADVALUE       -3
  36.  
  37. #ifndef _STDDEF
  38. #define _STDDEF
  39. #ifndef _PTRDIFF_T
  40. #define _PTRDIFF_T
  41. #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
  42.   typedef long  ptrdiff_t;
  43. #else
  44.   typedef int ptrdiff_t;
  45. #endif
  46. #endif
  47. #ifndef _SIZE_T
  48.   #define _SIZE_T
  49.   typedef unsigned size_t;
  50. #endif
  51. #endif
  52.  
  53. #if !defined(_Windows)
  54.  
  55. #if !defined(__STDC__)  /* NON_ANSI */
  56. struct farheapinfo
  57.   {
  58.   void huge *ptr;
  59.   unsigned long size;
  60.   int in_use;
  61.   };
  62. #endif
  63.  
  64. #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  65. struct heapinfo
  66.   {
  67.   void _FAR *ptr;
  68.   unsigned int size;
  69.   int in_use;
  70.   };
  71. #else
  72. #define heapinfo farheapinfo
  73. #endif
  74.  
  75. #endif  /* WINDOWS */
  76.  
  77. #ifdef __cplusplus
  78. extern "C" {
  79. #endif
  80.  
  81. void  _FAR *_Cdecl calloc(size_t __nitems, size_t __size);
  82. void        _Cdecl free(void _FAR *__block);
  83. void  _FAR *_Cdecl malloc(size_t __size);
  84. void  _FAR *_Cdecl realloc(void _FAR *__block, size_t __size);
  85.  
  86. #if !defined(_Windows)
  87.  
  88. int         _Cdecl brk(void *__addr);
  89. void       *_Cdecl sbrk(int __incr);
  90.  
  91. int         _Cdecl heapcheck(void);
  92. int         _Cdecl heapfillfree(unsigned int __fillvalue);
  93. int         _Cdecl heapcheckfree(unsigned int __fillvalue);
  94.  
  95. #if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
  96.  
  97. unsigned long _Cdecl coreleft (void);
  98.  
  99. #if !defined(__STDC__)  /* NON_ANSI */
  100. int         _Cdecl heapchecknode(void far *__node);
  101. int         _Cdecl heapwalk(struct farheapinfo far *__hi);
  102. #endif
  103.  
  104. #else
  105.  
  106. unsigned    _Cdecl coreleft(void);
  107. int         _Cdecl heapchecknode(void *__node);
  108. int         _Cdecl heapwalk(struct heapinfo *__hi);
  109.  
  110. #endif
  111.  
  112. #if !defined(__STDC__)  /* NON_ANSI */
  113. unsigned long _Cdecl farcoreleft(void);
  114. int         _Cdecl farheapcheck(void);
  115. int         _Cdecl farheapchecknode(void far *__node);
  116. int         _Cdecl farheapfillfree(unsigned int __fillvalue);
  117. int         _Cdecl farheapcheckfree(unsigned int __fillvalue);
  118. int         _Cdecl farheapwalk(struct farheapinfo *__hi);
  119. #endif
  120.  
  121. #endif  /* WINDOWS */
  122.  
  123. #if !defined(__STDC__)  /* NON_ANSI */
  124. void far  * _Cdecl farcalloc(unsigned long __nunits, unsigned long __unitsz);
  125. void        _Cdecl farfree(void far *__block);
  126. void far  * _Cdecl farmalloc(unsigned long __nbytes);
  127. void far  * _Cdecl farrealloc(void far *__oldblock, unsigned long __nbytes);
  128. #endif
  129.  
  130. #ifdef __cplusplus
  131. }
  132. #endif
  133.  
  134.  
  135. #else  /* defined __FLAT__ */
  136.  
  137.  
  138. #ifndef _STDDEF
  139. #  define _STDDEF
  140. #  ifndef _PTRDIFF_T
  141. #    define _PTRDIFF_T
  142.      typedef int ptrdiff_t;
  143. #  endif
  144. #  ifndef _SIZE_T
  145. #    define _SIZE_T
  146.      typedef unsigned size_t;
  147. #  endif
  148. #endif
  149.  
  150. #if !defined(__STDC__)
  151. struct heapinfo
  152. {
  153.   void *    ptr;
  154.   unsigned  size;
  155.   int       in_use;
  156. };
  157. #endif
  158.  
  159. #ifdef __cplusplus
  160. extern "C" {
  161. #endif
  162.  
  163. void *_RTLENTRY _EXPFUNC calloc  (size_t __nitems, size_t __size);
  164. void  _RTLENTRY _EXPFUNC free    (void * __block);
  165. void *_RTLENTRY _EXPFUNC malloc  (size_t  __size);
  166. void *_RTLENTRY _EXPFUNC realloc (void * __block, size_t __size);
  167.  
  168. int   _RTLENTRY _EXPFUNC heapcheck    (void);
  169. int   _RTLENTRY _EXPFUNC heapfillfree (unsigned int __fillvalue);
  170. int   _RTLENTRY _EXPFUNC heapcheckfree(unsigned int __fillvalue);
  171. int   _RTLENTRY _EXPFUNC heapchecknode(void *__node);
  172. int   _RTLENTRY _EXPFUNC heapwalk     (struct heapinfo *__hi);
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176.  
  177. /* Values returned by heap??? and _heap??? functions */
  178.  
  179. #define _HEAPEMPTY      1
  180. #define _HEAPOK         2
  181. #define _FREEENTRY      3
  182. #define _USEDENTRY      4
  183. #define _HEAPEND        5
  184. #define _HEAPCORRUPT    -1
  185. #define _BADNODE        -2
  186. #define _BADVALUE       -3
  187. #define _HEAPBADBEGIN   -4
  188. #define _HEAPBADNODE    -5
  189. #define _HEAPBADPTR     -6
  190.  
  191.  
  192. #endif  /* __FLAT__ */
  193.  
  194. #endif  /* __ALLOC_H */
  195.  
  196.  
  197.