home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / MALLOC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-08  |  4.6 KB  |  211 lines

  1. #if !defined(__TOPLEVEL_NEXT_COMMON_INCLUDE__)
  2. #define __TOPLEVEL_NEXT_COMMON_INCLUDE__
  3. #define __TOPLEVEL_MALLOC_H_
  4. #include <next_common_defines.h>
  5. #endif /* __TOPLEVEL_NEXT_COMMON_INCLUDE__ */
  6.  
  7. /***
  8. *malloc.h - declarations and definitions for memory allocation functions
  9. *
  10. *       Copyright (c) 1985-1995, Microsoft Corporation. All rights reserved.
  11. *
  12. *Purpose:
  13. *       Contains the function declarations for memory allocation functions;
  14. *       also defines manifest constants and types used by the heap routines.
  15. *       [System V]
  16. *
  17. *       [Public]
  18. *
  19. ****/
  20.  
  21. #if _MSC_VER > 1000
  22. #pragma once
  23. #endif
  24.  
  25. #ifndef _INC_MALLOC
  26. #define _INC_MALLOC
  27.  
  28. #if !defined(_WIN32) && !defined(_MAC)
  29. #error ERROR: Only Mac or Win32 targets supported!
  30. #endif
  31.  
  32.  
  33. #ifdef  _MSC_VER
  34. /*
  35.  * Currently, all MS C compilers for Win32 platforms default to 8 byte
  36.  * alignment.
  37.  */
  38. #pragma pack(push,8)
  39. #endif  /* _MSC_VER */
  40.  
  41. #ifdef  __cplusplus
  42. extern "C" {
  43. #endif
  44.  
  45.  
  46. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  47.  
  48. #ifndef _CRTAPI1
  49. #if     _MSC_VER >= 800 && _M_IX86 >= 300
  50. #define _CRTAPI1 __cdecl
  51. #else
  52. #define _CRTAPI1
  53. #endif
  54. #endif
  55.  
  56.  
  57. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  58.  
  59. #ifndef _CRTAPI2
  60. #if     _MSC_VER >= 800 && _M_IX86 >= 300
  61. #define _CRTAPI2 __cdecl
  62. #else
  63. #define _CRTAPI2
  64. #endif
  65. #endif
  66.  
  67.  
  68. /* Define _CRTIMP */
  69.  
  70. #ifndef _CRTIMP
  71. #ifdef  _NTSDK
  72. /* definition compatible with NT SDK */
  73. #define _CRTIMP
  74. #else   /* ndef _NTSDK */
  75. /* current definition */
  76. #ifdef  _DLL
  77. #define _CRTIMP __declspec(dllimport)
  78. #else   /* ndef _DLL */
  79. #define _CRTIMP
  80. #endif  /* _DLL */
  81. #endif  /* _NTSDK */
  82. #endif  /* _CRTIMP */
  83.  
  84.  
  85. /* Define __cdecl for non-Microsoft compilers */
  86.  
  87. #if     ( !defined(_MSC_VER) && !defined(__cdecl) )
  88. #define __cdecl
  89. #endif
  90.  
  91.  
  92. #ifndef _SIZE_T_DEFINED
  93. typedef unsigned int size_t;
  94. #define _SIZE_T_DEFINED
  95. #endif
  96.  
  97.  
  98. /* Maximum heap request the heap manager will attempt */
  99.  
  100. #define _HEAP_MAXREQ    0xFFFFFFE0
  101.  
  102. /* Constants for _heapchk/_heapset/_heapwalk routines */
  103.  
  104. #define _HEAPEMPTY      (-1)
  105. #define _HEAPOK         (-2)
  106. #define _HEAPBADBEGIN   (-3)
  107. #define _HEAPBADNODE    (-4)
  108. #define _HEAPEND        (-5)
  109. #define _HEAPBADPTR     (-6)
  110. #define _FREEENTRY      0
  111. #define _USEDENTRY      1
  112.  
  113. #ifndef _HEAPINFO_DEFINED
  114. typedef struct _heapinfo {
  115.         int * _pentry;
  116.         size_t _size;
  117.         int _useflag;
  118.         } _HEAPINFO;
  119. #define _HEAPINFO_DEFINED
  120. #endif
  121.  
  122. #ifndef _NTSDK
  123.  
  124. /* External variable declarations */
  125.  
  126. #if     defined(_DLL) && defined(_M_IX86)
  127.  
  128. #define _amblksiz   (*__p__amblksiz())
  129. _CRTIMP unsigned int * __cdecl __p__amblksiz(void);
  130.  
  131. #else   /* !(defined(_DLL) && defined(_M_IX86)) */
  132.  
  133. extern unsigned int _amblksiz;
  134.  
  135. #endif  /* defined(_DLL) && defined(_M_IX86) */
  136.  
  137. #endif  /* _NTSDK */
  138.  
  139.  
  140. /* Function prototypes */
  141.  
  142. _CRTIMP void * __cdecl calloc(size_t, size_t);
  143. _CRTIMP void   __cdecl free(void *);
  144. _CRTIMP void * __cdecl malloc(size_t);
  145. _CRTIMP void * __cdecl realloc(void *, size_t);
  146. #if defined(_M_M68K) || defined(_M_MPPC)
  147. _CRTIMP size_t __cdecl _stackavail(void);
  148. #endif
  149.  
  150. #ifndef _POSIX_
  151.  
  152. void * __cdecl _alloca(size_t);
  153. _CRTIMP void * __cdecl _expand(void *, size_t);
  154. #ifndef _NTSDK
  155. _CRTIMP int __cdecl _heapadd(void *, size_t);
  156. _CRTIMP int __cdecl _heapchk(void);
  157. _CRTIMP int __cdecl _heapmin(void);
  158. _CRTIMP int __cdecl _heapset(unsigned int);
  159. _CRTIMP int __cdecl _heapwalk(_HEAPINFO *);
  160. _CRTIMP size_t __cdecl _heapused(size_t *, size_t *);
  161. #endif  /* _NTSDK */
  162. _CRTIMP size_t __cdecl _msize(void *);
  163.  
  164. #ifndef __GNUC__ 
  165. #if     !__STDC__
  166. /* Non-ANSI names for compatibility */
  167. #define alloca  _alloca
  168. #endif  /* __STDC__*/
  169. #endif/* __GNUC__ */
  170.  
  171. #if defined(_M_MRX000) || defined(_M_PPC) || defined(_M_ALPHA)
  172. #pragma intrinsic(_alloca)
  173. #endif
  174.  
  175. #endif  /* _POSIX_ */
  176.  
  177. #ifdef HEAPHOOK
  178. #ifndef _HEAPHOOK_DEFINED
  179. /* hook function type */
  180. typedef int (__cdecl * _HEAPHOOK)(int, size_t, void *, void **);
  181. #define _HEAPHOOK_DEFINED
  182. #endif /* _HEAPHOOK_DEFINED */
  183.  
  184. /* set hook function */
  185. _CRTIMP _HEAPHOOK __cdecl _setheaphook(_HEAPHOOK);
  186.  
  187. /* hook function must handle these types */
  188. #define _HEAP_MALLOC    1
  189. #define _HEAP_CALLOC    2
  190. #define _HEAP_FREE      3
  191. #define _HEAP_REALLOC   4
  192. #define _HEAP_MSIZE     5
  193. #define _HEAP_EXPAND    6
  194. #endif /* HEAPHOOK */
  195.  
  196.  
  197. #ifdef  __cplusplus
  198. }
  199. #endif
  200.  
  201.  
  202. #ifdef  _MSC_VER
  203. #pragma pack(pop)
  204. #endif  /* _MSC_VER */
  205.  
  206. #endif  /* _INC_MALLOC */
  207. #if defined(__TOPLEVEL_MALLOC_H_)
  208. #undef __TOPLEVEL_NEXT_COMMON_INCLUDE__
  209. #undef __TOPLEVEL_MALLOC_H_ 
  210. #include <next_common_undefines.h>
  211. #endif /* __TOPLEVEL_MALLOC_H_ */