198 _STATIC_ASSERT(sizeof(unsigned&nbsp;int) <= _ALLOCA_S_MARKER_SIZE);

199

200 #if !defined(__midl) && !defined(RC_INVOKED)

201 #pragma warning(push)


202 #pragma warning(disable:6540)

203 __inline void&nbsp;*_MarkAllocaS(_Out_opt_ __crt_typefix(unsigned&nbsp;int*) void&nbsp;*_Ptr, unsigned&nbsp;int&nbsp;_Marker)


204 {

205 &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(_Ptr)

206 &nbsp;&nbsp;&nbsp;&nbsp;{

207 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*((unsigned&nbsp;int*)_Ptr) = _Marker;

208 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_Ptr = (char*)_Ptr + _ALLOCA_S_MARKER_SIZE;


209 &nbsp;&nbsp;&nbsp;&nbsp;}

210 &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;_Ptr;

211 }

212 #pragma warning(pop)

213 #endif

214


215 #if defined(_DEBUG)

216 #if !defined(_CRTDBG_MAP_ALLOC)

217 #undef _malloca

218 #define _malloca(size) \

219 __pragma(warning(suppress: 6255)) \


220 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_MarkAllocaS(malloc((size) + _ALLOCA_S_MARKER_SIZE), _ALLOCA_S_HEAP_MARKER)

221 #endif

222 #else

223 #undef _malloca

224 #define _malloca(size) \

225 __pragma(warning(suppress: 6255)) \


226 &nbsp;&nbsp;&nbsp;&nbsp;((((size) + _ALLOCA_S_MARKER_SIZE) <= _ALLOCA_S_THRESHOLD) ? \

227 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_MarkAllocaS(_alloca((size) + _ALLOCA_S_MARKER_SIZE), _ALLOCA_S_STACK_MARKER) : \

228 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_MarkAllocaS(malloc((size) + _ALLOCA_S_MARKER_SIZE), _ALLOCA_S_HEAP_MARKER))

229 #endif

230

231 #undef _FREEA_INLINE


232 #define _FREEA_INLINE

233

234 #ifdef _FREEA_INLINE

235 /*&nbsp;_freea must be in the header so that its allocator matches _malloca */

236 #if !defined(__midl) && !defined(RC_INVOKED)


237 #undef _freea

238 _CRTNOALIAS __inline void&nbsp;__CRTDECL _freea(_Inout_opt_ void&nbsp;* _Memory)

239 {

240 &nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;int&nbsp;_Marker;


241 &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(_Memory)

242 &nbsp;&nbsp;&nbsp;&nbsp;{

243 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_Memory = (char*)_Memory - _ALLOCA_S_MARKER_SIZE;

244 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_Marker = *(unsigned&nbsp;int&nbsp;*)_Memory;


245 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(_Marker == _ALLOCA_S_HEAP_MARKER)

246 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{

247 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free(_Memory);

248 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

249 #if defined(_ASSERTE)

250 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(_Marker != _ALLOCA_S_STACK_MARKER)


251 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{

252 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_ASSERTE((&quot;Corrupted pointer passed to _freea&quot;, 0));

253 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

254 #endif

255 &nbsp;&nbsp;&nbsp;&nbsp;}


256 }

257 #endif

258 #endif

259

260 #if&nbsp;&nbsp;&nbsp;&nbsp; !__STDC__

261 /*&nbsp;Non-ANSI names for compatibility */


262 #define alloca&nbsp;&nbsp;_alloca

263 #endif&nbsp;&nbsp;/*&nbsp;__STDC__*/

264

265 #endif&nbsp;&nbsp;/*&nbsp;_POSIX_ */


266

267 #ifdef&nbsp;&nbsp;HEAPHOOK

268 #ifndef _HEAPHOOK_DEFINED

269 /*&nbsp;hook function type */

270 typedef&nbsp;int&nbsp;(__cdecl * _HEAPHOOK)(int, size_t, void&nbsp;*, void&nbsp;**);


271 #define _HEAPHOOK_DEFINED

272 #endif&nbsp;&nbsp;/*&nbsp;_HEAPHOOK_DEFINED */

273

274 /*&nbsp;set hook function */

275 _CRTIMP _HEAPHOOK __cdecl _setheaphook(_In_opt_ _HEAPHOOK _NewHook);


276

277 /*&nbsp;hook function must handle these types */

278 #define _HEAP_MALLOC&nbsp;&nbsp;&nbsp;&nbsp;1

279 #define _HEAP_CALLOC&nbsp;&nbsp;&nbsp;&nbsp;2

280 #define _HEAP_FREE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3


281 #define _HEAP_REALLOC&nbsp;&nbsp; 4

282 #define _HEAP_MSIZE&nbsp;&nbsp;&nbsp;&nbsp; 5

283 #define _HEAP_EXPAND&nbsp;&nbsp;&nbsp;&nbsp;6

284 #endif&nbsp;&nbsp;/*&nbsp;HEAPHOOK */


285

286

287 #ifdef&nbsp;&nbsp;__cplusplus

288 }

289 #endif

290

291 #ifdef&nbsp;&nbsp;_MSC_VER


292 #pragma pack(pop)

293 #endif&nbsp;&nbsp;/*&nbsp;_MSC_VER */

294