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.

177 lines
4.0 KiB

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