home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / malloc.h < prev    next >
C/C++ Source or Header  |  1998-06-16  |  4KB  |  167 lines

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