home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / malloc.h < prev    next >
C/C++ Source or Header  |  1998-06-17  |  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  /* _MSC_VER > 1000 */
  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  /* !defined (_WIN32) && !defined (_MAC) */
  25.  
  26. #ifndef _CRTBLD
  27. /* This version of the header files is NOT for user programs.
  28.  * It is intended for use when building the C runtimes ONLY.
  29.  * The version intended for public use will not have this message.
  30.  */
  31. #error ERROR: Use of C runtime library internal header file.
  32. #endif  /* _CRTBLD */
  33.  
  34. #ifdef _MSC_VER
  35. /*
  36.  * Currently, all MS C compilers for Win32 platforms default to 8 byte
  37.  * alignment.
  38.  */
  39. #pragma pack(push,8)
  40. #endif  /* _MSC_VER */
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif  /* __cplusplus */
  45.  
  46. #ifndef _INTERNAL_IFSTRIP_
  47. #include <cruntime.h>
  48. #endif  /* _INTERNAL_IFSTRIP_ */
  49.  
  50. /* Define _CRTIMP */
  51.  
  52. #ifndef _CRTIMP
  53. #ifdef CRTDLL
  54. #define _CRTIMP __declspec(dllexport)
  55. #else  /* CRTDLL */
  56. #ifdef _DLL
  57. #define _CRTIMP __declspec(dllimport)
  58. #else  /* _DLL */
  59. #define _CRTIMP
  60. #endif  /* _DLL */
  61. #endif  /* CRTDLL */
  62. #endif  /* _CRTIMP */
  63.  
  64.  
  65. /* Define __cdecl for non-Microsoft compilers */
  66.  
  67. #if (!defined (_MSC_VER) && !defined (__cdecl))
  68. #define __cdecl
  69. #endif  /* (!defined (_MSC_VER) && !defined (__cdecl)) */
  70.  
  71. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  72.  
  73. #ifndef _CRTAPI1
  74. #if _MSC_VER >= 800 && _M_IX86 >= 300
  75. #define _CRTAPI1 __cdecl
  76. #else  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  77. #define _CRTAPI1
  78. #endif  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  79. #endif  /* _CRTAPI1 */
  80.  
  81.  
  82. #ifndef _SIZE_T_DEFINED
  83. typedef unsigned int size_t;
  84. #define _SIZE_T_DEFINED
  85. #endif  /* _SIZE_T_DEFINED */
  86.  
  87.  
  88. /* Maximum heap request the heap manager will attempt */
  89.  
  90. #define _HEAP_MAXREQ    0xFFFFFFE0
  91.  
  92. /* Constants for _heapchk/_heapset/_heapwalk routines */
  93.  
  94. #define _HEAPEMPTY      (-1)
  95. #define _HEAPOK         (-2)
  96. #define _HEAPBADBEGIN   (-3)
  97. #define _HEAPBADNODE    (-4)
  98. #define _HEAPEND        (-5)
  99. #define _HEAPBADPTR     (-6)
  100. #define _FREEENTRY      0
  101. #define _USEDENTRY      1
  102.  
  103. #ifndef _HEAPINFO_DEFINED
  104. typedef struct _heapinfo {
  105.         int * _pentry;
  106.         size_t _size;
  107.         int _useflag;
  108.         } _HEAPINFO;
  109. #define _HEAPINFO_DEFINED
  110. #endif  /* _HEAPINFO_DEFINED */
  111.  
  112. /* External variable declarations */
  113. #ifndef _INTERNAL_IFSTRIP_
  114. #if defined (_DLL) && defined (_M_IX86)
  115. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  116. _CRTIMP unsigned int * __cdecl __p__amblksiz(void);
  117. #endif  /* defined (_DLL) && defined (_M_IX86) */
  118. #endif  /* _INTERNAL_IFSTRIP_ */
  119.  
  120. extern unsigned int _amblksiz;
  121.  
  122.  
  123. /* Function prototypes */
  124.  
  125. _CRTIMP void *  __cdecl calloc(size_t, size_t);
  126. _CRTIMP void    __cdecl free(void *);
  127. _CRTIMP void *  __cdecl malloc(size_t);
  128. _CRTIMP void *  __cdecl realloc(void *, size_t);
  129. #ifdef _MAC
  130. _CRTIMP size_t  __cdecl _stackavail(void);
  131. #endif  /* _MAC */
  132.  
  133.  
  134. void *          __cdecl _alloca(size_t);
  135. _CRTIMP void *  __cdecl _expand(void *, size_t);
  136. _CRTIMP size_t  __cdecl _get_sbh_threshold(void);
  137. _CRTIMP int     __cdecl _set_sbh_threshold(size_t);
  138. _CRTIMP int     __cdecl _heapadd(void *, size_t);
  139. _CRTIMP int     __cdecl _heapchk(void);
  140. _CRTIMP int     __cdecl _heapmin(void);
  141. _CRTIMP int     __cdecl _heapset(unsigned int);
  142. _CRTIMP int     __cdecl _heapwalk(_HEAPINFO *);
  143. _CRTIMP size_t  __cdecl _heapused(size_t *, size_t *);
  144. _CRTIMP size_t  __cdecl _msize(void *);
  145.  
  146. #if !__STDC__
  147. /* Non-ANSI names for compatibility */
  148. #define alloca  _alloca
  149. #endif  /* !__STDC__ */
  150.  
  151. #if defined (_M_MRX000) || defined (_M_PPC) || defined (_M_ALPHA)
  152. #pragma intrinsic(_alloca)
  153. #endif  /* defined (_M_MRX000) || defined (_M_PPC) || defined (_M_ALPHA) */
  154.  
  155.  
  156.  
  157.  
  158. #ifdef __cplusplus
  159. }
  160. #endif  /* __cplusplus */
  161.  
  162. #ifdef _MSC_VER
  163. #pragma pack(pop)
  164. #endif  /* _MSC_VER */
  165.  
  166. #endif  /* _INC_MALLOC */
  167.