Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
3.9 KiB

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