1 // 2 // corecrt_malloc.h 3 // 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // 6 // The memory allocation library. These pieces of the allocation library are 7 // shared by both <stdlib.h> and <malloc.h>. 8 // 9 #pragma once 10 11 #include <corecrt.h> 12 13 #pragma warning(push) 14 #pragma warning(disable: _UCRT_DISABLED_WARNINGS) 15 _UCRT_DISABLE_CLANG_WARNINGS 16 17 _CRT_BEGIN_C_HEADER 18 19 20 21 #if defined _DEBUG && defined _CRTDBG_MAP_ALLOC 22 #pragma push_macro("_aligned_free") 23 #pragma push_macro("_aligned_malloc") 24 #pragma push_macro("_aligned_msize") 25 #pragma push_macro("_aligned_offset_malloc") 26 #pragma push_macro("_aligned_offset_realloc") 27 #pragma push_macro("_aligned_offset_recalloc") 28 #pragma push_macro("_aligned_realloc") 29 #pragma push_macro("_aligned_recalloc") 30 #pragma push_macro("_expand") 31 #pragma push_macro("_freea") 32 #pragma push_macro("_msize") 33 #pragma push_macro("_recalloc") 34 #pragma push_macro("calloc") 35 #pragma push_macro("free") 36 #pragma push_macro("malloc") 37 #pragma push_macro("realloc") 38 39 #undef _aligned_free 40 #undef _aligned_malloc 41 #undef _aligned_msize 42 #undef _aligned_offset_malloc 43 #undef _aligned_offset_realloc 44 #undef _aligned_offset_recalloc 45 #undef _aligned_realloc 46 #undef _aligned_recalloc 47 #undef _expand 48 #undef _freea 49 #undef _msize 50 #undef _recalloc 51 #undef calloc 52 #undef free 53 #undef malloc 54 #undef realloc 55 #endif 56 57 _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) 58 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 59 void* __cdecl _calloc_base( 60 _In_ size_t _Count, 61 _In_ size_t _Size 62 ); 63 64 _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) 65 _ACRTIMP _CRT_JIT_INTRINSIC _CRTALLOCATOR _CRTRESTRICT _CRT_HYBRIDPATCHABLE 66 void* __cdecl calloc( 67 _In_ _CRT_GUARDOVERFLOW size_t _Count, 68 _In_ _CRT_GUARDOVERFLOW size_t _Size 69 ); 70 71 _Check_return_ 72 _ACRTIMP int __cdecl _callnewh( 73 _In_ size_t _Size 74 ); 75 76 _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) 77 _ACRTIMP _CRTALLOCATOR _CRT_HYBRIDPATCHABLE 78 void* __cdecl _expand( 79 _Pre_notnull_ void* _Block, 80 _In_ _CRT_GUARDOVERFLOW size_t _Size 81 ); 82 83 _ACRTIMP 84 void __cdecl _free_base( 85 _Pre_maybenull_ _Post_invalid_ void* _Block 86 ); 87 88 _ACRTIMP _CRT_HYBRIDPATCHABLE 89 void __cdecl free( 90 _Pre_maybenull_ _Post_invalid_ void* _Block 91 ); 92 93 _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) 94 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 95 void* __cdecl _malloc_base( 96 _In_ size_t _Size 97 ); 98 99 _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) 100 _ACRTIMP _CRTALLOCATOR _CRT_JIT_INTRINSIC _CRTRESTRICT _CRT_HYBRIDPATCHABLE 101 void* __cdecl malloc( 102 _In_ _CRT_GUARDOVERFLOW size_t _Size 103 ); 104 105 _Check_return_ 106 _ACRTIMP 107 size_t __cdecl _msize_base( 108 _Pre_notnull_ void* _Block 109 ) _CRT_NOEXCEPT; 110 111 _Check_return_ 112 _ACRTIMP _CRT_HYBRIDPATCHABLE 113 size_t __cdecl _msize( 114 _Pre_notnull_ void* _Block 115 ); 116 117 _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) 118 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 119 void* __cdecl _realloc_base( 120 _Pre_maybenull_ _Post_invalid_ void* _Block, 121 _In_ size_t _Size 122 ); 123 124 _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) 125 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT _CRT_HYBRIDPATCHABLE 126 void* __cdecl realloc( 127 _Pre_maybenull_ _Post_invalid_ void* _Block, 128 _In_ _CRT_GUARDOVERFLOW size_t _Size 129 ); 130 131 _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) 132 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 133 void* __cdecl _recalloc_base( 134 _Pre_maybenull_ _Post_invalid_ void* _Block, 135 _In_ size_t _Count, 136 _In_ size_t _Size 137 ); 138 139 _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) 140 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 141 void* __cdecl _recalloc( 142 _Pre_maybenull_ _Post_invalid_ void* _Block, 143 _In_ _CRT_GUARDOVERFLOW size_t _Count, 144 _In_ _CRT_GUARDOVERFLOW size_t _Size 145 ); 146 147 _ACRTIMP 148 void __cdecl _aligned_free( 149 _Pre_maybenull_ _Post_invalid_ void* _Block 150 ); 151 152 _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) 153 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 154 void* __cdecl _aligned_malloc( 155 _In_ _CRT_GUARDOVERFLOW size_t _Size, 156 _In_ size_t _Alignment 157 ); 158 159 _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) 160 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 161 void* __cdecl _aligned_offset_malloc( 162 _In_ _CRT_GUARDOVERFLOW size_t _Size, 163 _In_ size_t _Alignment, 164 _In_ size_t _Offset 165 ); 166 167 _Check_return_ 168 _ACRTIMP 169 size_t __cdecl _aligned_msize( 170 _Pre_notnull_ void* _Block, 171 _In_ size_t _Alignment, 172 _In_ size_t _Offset 173 ); 174 175 _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) 176 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 177 void* __cdecl _aligned_offset_realloc( 178 _Pre_maybenull_ _Post_invalid_ void* _Block, 179 _In_ _CRT_GUARDOVERFLOW size_t _Size, 180 _In_ size_t _Alignment, 181 _In_ size_t _Offset 182 ); 183 184 _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) 185 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 186 void* __cdecl _aligned_offset_recalloc( 187 _Pre_maybenull_ _Post_invalid_ void* _Block, 188 _In_ _CRT_GUARDOVERFLOW size_t _Count, 189 _In_ _CRT_GUARDOVERFLOW size_t _Size, 190 _In_ size_t _Alignment, 191 _In_ size_t _Offset 192 ); 193 194 _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) 195 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 196 void* __cdecl _aligned_realloc( 197 _Pre_maybenull_ _Post_invalid_ void* _Block, 198 _In_ _CRT_GUARDOVERFLOW size_t _Size, 199 _In_ size_t _Alignment 200 ); 201 202 _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) 203 _ACRTIMP _CRTALLOCATOR _CRTRESTRICT 204 void* __cdecl _aligned_recalloc( 205 _Pre_maybenull_ _Post_invalid_ void* _Block, 206 _In_ _CRT_GUARDOVERFLOW size_t _Count, 207 _In_ _CRT_GUARDOVERFLOW size_t _Size, 208 _In_ size_t _Alignment 209 ); 210 211 #if defined _DEBUG && defined _CRTDBG_MAP_ALLOC 212 #pragma pop_macro("realloc") 213 #pragma pop_macro("malloc") 214 #pragma pop_macro("free") 215 #pragma pop_macro("calloc") 216 #pragma pop_macro("_recalloc") 217 #pragma pop_macro("_msize") 218 #pragma pop_macro("_freea") 219 #pragma pop_macro("_expand") 220 #pragma pop_macro("_aligned_recalloc") 221 #pragma pop_macro("_aligned_realloc") 222 #pragma pop_macro("_aligned_offset_recalloc") 223 #pragma pop_macro("_aligned_offset_realloc") 224 #pragma pop_macro("_aligned_offset_malloc") 225 #pragma pop_macro("_aligned_msize") 226 #pragma pop_macro("_aligned_malloc") 227 #pragma pop_macro("_aligned_free") 228 #endif 229 230 231 232 _CRT_END_C_HEADER 233 _UCRT_RESTORE_CLANG_WARNINGS 234 #pragma warning(pop) // _UCRT_DISABLED_WARNINGS 235