File Index Symbol Index

//
// malloc.h
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The memory allocation library.
//
#pragma once
#ifndef _INC_MALLOC // include guard for 3rd party interop
#define _INC_MALLOC
#include <corecrt.h>
#include <corecrt_malloc.h>
// Maximum heap request the heap manager will attempt
#ifdef _WIN64
#define _HEAP_MAXREQ 0xFFFFFFFFFFFFFFE0
#else
#define _HEAP_MAXREQ 0xFFFFFFE0 #endif
// Constants for _heapchk and _heapwalk routines
#define _HEAPEMPTY (-1)
#define _HEAPOK (-2)
#define _HEAPBADBEGIN (-3)
#define _HEAPBADNODE (-4)
#define _HEAPEND (-5)
#define _HEAPBADPTR (-6)
#define _FREEENTRY 0
#define _USEDENTRY 1
typedef
struct
_heapinfo
{
int
*
_pentry
;
size_t
_size
;
int
_useflag
; }
_HEAPINFO
;
#define _mm_free(a) _aligned_free(a)
#define _mm_malloc(a, b) _aligned_malloc(a, b)
_Ret_notnull_ _Post_writable_byte_size_(_Size)
#if !defined __midl && !defined RC_INVOKED
_Check_return_
#if defined _DEBUG || defined _CRT_USE_WINAPI_FAMILY_DESKTOP_APP || defined _CORECRT_BUILD
#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
#define _ALLOCA_S_THRESHOLD 1024
#define _ALLOCA_S_STACK_MARKER 0xCCCC
#define _ALLOCA_S_HEAP_MARKER 0xDDDD
#ifdef _WIN64
#define _ALLOCA_S_MARKER_SIZE 16
#else
#define _ALLOCA_S_MARKER_SIZE 8 #endif
{
if
(
_Ptr
) { *((
unsigned
int
*)
_Ptr
) =
_Marker
; }
return
_Ptr
; }
__inline
size_t
_MallocaComputeSize
(
size_t
_Size
) {
return
_MarkedSize
>
_Size
?
_MarkedSize
:
0
; }
#endif
#ifdef _DEBUG
#ifndef _CRTDBG_MAP_ALLOC
#undef _malloca
#define _malloca(size) \
__pragma(warning(suppress: 6255 6386)) \
(_MallocaComputeSize(size) != 0 \
? _MarkAllocaS(malloc(_MallocaComputeSize(size)), _ALLOCA_S_HEAP_MARKER) \
: NULL) #endif
#else
#undef _malloca
#define _malloca(size) \
__pragma(warning(suppress: 6255 6386)) \
(_MallocaComputeSize(size) != 0 \
? (((_MallocaComputeSize(size) <= _ALLOCA_S_THRESHOLD) \
? _MarkAllocaS(_alloca(_MallocaComputeSize(size)), _ALLOCA_S_STACK_MARKER) \
: _MarkAllocaS(malloc(_MallocaComputeSize(size)), _ALLOCA_S_HEAP_MARKER))) \
: NULL)
#endif
#if defined __midl && !defined RC_INVOKED #elif defined _DEBUG && defined _CRTDBG_MAP_ALLOC #else
#undef _freea
{
unsigned
int
_Marker
;
if
(
_Memory
) {
_Marker
= *(
unsigned
int
*)
_Memory
; {
free
(
_Memory
); }
#ifdef _ASSERTE
{ }
#endif
} }
#endif
#if _CRT_INTERNAL_NONSTDC_NAMES
#define alloca _alloca #endif