ReactOS 0.4.16-dev-814-g656a5dc
malloc.h File Reference
#include <corecrt.h>
#include <corecrt_malloc.h>
Include dependency graph for malloc.h:

Go to the source code of this file.

Classes

struct  _heapinfo
 

Macros

#define _INC_MALLOC
 
#define _HEAP_MAXREQ   0xFFFFFFE0
 
#define _HEAPEMPTY   (-1)
 
#define _HEAPOK   (-2)
 
#define _HEAPBADBEGIN   (-3)
 
#define _HEAPBADNODE   (-4)
 
#define _HEAPEND   (-5)
 
#define _HEAPBADPTR   (-6)
 
#define _FREEENTRY   0
 
#define _USEDENTRY   1
 
#define _mm_free(a)   _aligned_free(a)
 
#define _mm_malloc(a, b)   _aligned_malloc(a, b)
 
#define _ALLOCA_S_THRESHOLD   1024
 
#define _ALLOCA_S_STACK_MARKER   0xCCCC
 
#define _ALLOCA_S_HEAP_MARKER   0xDDDD
 
#define _ALLOCA_S_MARKER_SIZE   8
 
#define _malloca(size)
 

Typedefs

typedef struct _heapinfo _HEAPINFO
 

Functions

_Ret_notnull_ _Post_writable_byte_size_ (_Size) void *__cdecl _alloca(_In_ size_t _Size)
 
_ACRTIMP intptr_t __cdecl _get_heap_handle (void)
 
_Check_return_ _DCRTIMP int __cdecl _heapmin (void)
 
_DCRTIMP int __cdecl _resetstkoflw (void)
 
 _STATIC_ASSERT (sizeof(unsigned int)<=_ALLOCA_S_MARKER_SIZE)
 
__inline void_MarkAllocaS (_Out_opt_ __crt_typefix(unsigned int *) void *_Ptr, unsigned int _Marker)
 
__inline size_t _MallocaComputeSize (size_t _Size)
 
__inline void __CRTDECL _freea (_Pre_maybenull_ _Post_invalid_ void *_Memory)
 

Macro Definition Documentation

◆ _ALLOCA_S_HEAP_MARKER

#define _ALLOCA_S_HEAP_MARKER   0xDDDD

Definition at line 81 of file malloc.h.

◆ _ALLOCA_S_MARKER_SIZE

#define _ALLOCA_S_MARKER_SIZE   8

Definition at line 86 of file malloc.h.

◆ _ALLOCA_S_STACK_MARKER

#define _ALLOCA_S_STACK_MARKER   0xCCCC

Definition at line 80 of file malloc.h.

◆ _ALLOCA_S_THRESHOLD

#define _ALLOCA_S_THRESHOLD   1024

Definition at line 79 of file malloc.h.

◆ _FREEENTRY

#define _FREEENTRY   0

Definition at line 39 of file malloc.h.

◆ _HEAP_MAXREQ

#define _HEAP_MAXREQ   0xFFFFFFE0

Definition at line 27 of file malloc.h.

◆ _HEAPBADBEGIN

#define _HEAPBADBEGIN   (-3)

Definition at line 35 of file malloc.h.

◆ _HEAPBADNODE

#define _HEAPBADNODE   (-4)

Definition at line 36 of file malloc.h.

◆ _HEAPBADPTR

#define _HEAPBADPTR   (-6)

Definition at line 38 of file malloc.h.

◆ _HEAPEMPTY

#define _HEAPEMPTY   (-1)

Definition at line 33 of file malloc.h.

◆ _HEAPEND

#define _HEAPEND   (-5)

Definition at line 37 of file malloc.h.

◆ _HEAPOK

#define _HEAPOK   (-2)

Definition at line 34 of file malloc.h.

◆ _INC_MALLOC

#define _INC_MALLOC

Definition at line 10 of file malloc.h.

◆ _malloca

#define _malloca (   size)
Value:
__pragma(warning(suppress: 6255 6386)) \
: NULL)
#define _ALLOCA_S_STACK_MARKER
Definition: malloc.h:308
static __inline void * _MarkAllocaS(void *_Ptr, unsigned int _Marker)
Definition: malloc.h:320
#define _ALLOCA_S_HEAP_MARKER
Definition: malloc.h:309
#define _ALLOCA_S_THRESHOLD
Definition: malloc.h:307
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
GLsizeiptr size
Definition: glext.h:5919
boolean suppress
Definition: jpeglib.h:1006
#define __pragma(x)
Definition: debug.h:260
#define warning(s)
Definition: debug.h:83
__inline size_t _MallocaComputeSize(size_t _Size)
Definition: malloc.h:106

Definition at line 133 of file malloc.h.

◆ _mm_free

#define _mm_free (   a)    _aligned_free(a)

Definition at line 49 of file malloc.h.

◆ _mm_malloc

#define _mm_malloc (   a,
  b 
)    _aligned_malloc(a, b)

Definition at line 50 of file malloc.h.

◆ _USEDENTRY

#define _USEDENTRY   1

Definition at line 40 of file malloc.h.

Typedef Documentation

◆ _HEAPINFO

Function Documentation

◆ _freea()

Definition at line 153 of file malloc.h.

154 {
155 unsigned int _Marker;
156 if (_Memory)
157 {
158 _Memory = (char*)_Memory - _ALLOCA_S_MARKER_SIZE;
159 _Marker = *(unsigned int*)_Memory;
160 if (_Marker == _ALLOCA_S_HEAP_MARKER)
161 {
162 free(_Memory);
163 }
164 #ifdef _ASSERTE
165 else if (_Marker != _ALLOCA_S_STACK_MARKER)
166 {
167 _ASSERTE(("Corrupted pointer passed to _freea" && 0));
168 }
169 #endif
170 }
171 }
#define _ASSERTE(expr)
Definition: crtdbg.h:114
#define free
Definition: debug_ros.c:5
#define _ALLOCA_S_MARKER_SIZE
Definition: malloc.h:86

◆ _get_heap_handle()

_ACRTIMP intptr_t __cdecl _get_heap_handle ( void  )

Definition at line 367 of file heap.c.

368{
369 return (intptr_t)heap;
370}
static HANDLE heap
Definition: heap.c:65
int intptr_t
Definition: vcruntime.h:134

◆ _heapmin()

Definition at line 133 of file malloc.c.

134{
135 if (!HeapCompact(GetProcessHeap(), 0))
136 return -1;
137 return 0;
138}
#define GetProcessHeap()
Definition: compat.h:736
SIZE_T WINAPI HeapCompact(HANDLE hHeap, DWORD dwFlags)
Definition: heapmem.c:145

◆ _MallocaComputeSize()

__inline size_t _MallocaComputeSize ( size_t  _Size)

Definition at line 106 of file malloc.h.

107 {
108 size_t _MarkedSize = _Size + _ALLOCA_S_MARKER_SIZE;
109 return _MarkedSize > _Size ? _MarkedSize : 0;
110 }
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Size
Definition: malloc.h:109

◆ _MarkAllocaS()

__inline void * _MarkAllocaS ( _Out_opt_ __crt_typefix(unsigned int *) void _Ptr,
unsigned int  _Marker 
)

Definition at line 96 of file malloc.h.

97 {
98 if (_Ptr)
99 {
100 *((unsigned int*)_Ptr) = _Marker;
101 _Ptr = (char*)_Ptr + _ALLOCA_S_MARKER_SIZE;
102 }
103 return _Ptr;
104 }

◆ _Post_writable_byte_size_()

_Ret_notnull_ _Post_writable_byte_size_ ( _Size  )

◆ _resetstkoflw()

_DCRTIMP int __cdecl _resetstkoflw ( void  )

Definition at line 38 of file stack.c.

39{
40 int stack_addr;
41 DWORD oldprot;
42
43 /* causes stack fault that updates NtCurrentTeb()->Tib.StackLimit */
44 return VirtualProtect(&stack_addr, 1, PAGE_GUARD|PAGE_READWRITE, &oldprot);
45}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define PAGE_GUARD
Definition: nt_native.h:1310
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:135

◆ _STATIC_ASSERT()

_STATIC_ASSERT ( sizeof(unsigned int)<=  _ALLOCA_S_MARKER_SIZE)