ReactOS 0.4.15-dev-7788-g1ad9096
malloc.h File Reference
#include <crtdefs.h>
Include dependency graph for malloc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _heapinfo
 

Macros

#define _MM_MALLOC_H_INCLUDED
 
#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 _HEAPINFO_DEFINED
 
#define _mm_free(a)   _aligned_free(a)
 
#define _mm_malloc(a, b)   _aligned_malloc(a,b)
 
#define _CRT_ALLOCATION_DEFINED
 
#define _MAX_WAIT_MALLOC_CRT   60000
 
#define _ALLOCA_S_THRESHOLD   1024
 
#define _ALLOCA_S_STACK_MARKER   0xCCCC
 
#define _ALLOCA_S_HEAP_MARKER   0xDDDD
 
#define _malloca(size)
 
#define _FREEA_INLINE
 
#define alloca   _alloca
 

Typedefs

typedef struct _heapinfo _HEAPINFO
 

Functions

_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ (_NumOfElements *_SizeOfElements) void *__cdecl calloc(_In_ size_t _NumOfElements
 
void __cdecl free (_Pre_maybenull_ _Post_invalid_ void *_Memory)
 
_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ (_Size) void *__cdecl malloc(_In_ size_t _Size)
 
_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ (_NewSize) void *__cdecl realloc(_Pre_maybenull_ _Post_invalid_ void *_Memory
 
_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ (_Count *_Size) _CRTIMP void *__cdecl _recalloc(_Pre_maybenull_ _Post_invalid_ void *_Memory
 
_CRTIMP int __cdecl _resetstkoflw (void)
 
_CRTIMP unsigned long __cdecl _set_malloc_crt_max_wait (_In_ unsigned long _NewValue)
 
_Check_return_ _CRTIMP size_t __cdecl _msize (_In_ void *_Memory)
 
_Check_return_ _CRTIMP size_t __cdecl _get_sbh_threshold (void)
 
_CRTIMP int __cdecl _set_sbh_threshold (_In_ size_t _NewValue)
 
_CRTIMP errno_t __cdecl _set_amblksiz (_In_ size_t _Value)
 
_CRTIMP errno_t __cdecl _get_amblksiz (_Out_ size_t *_Value)
 
_Check_return_ _CRTIMP int __cdecl _heapadd (_In_ void *_Memory, _In_ size_t _Size)
 
_Check_return_ _CRTIMP int __cdecl _heapchk (void)
 
_Check_return_ _CRTIMP int __cdecl _heapmin (void)
 
_CRTIMP int __cdecl _heapset (_In_ unsigned int _Fill)
 
_CRTIMP int __cdecl _heapwalk (_Inout_ _HEAPINFO *_EntryInfo)
 
_CRTIMP size_t __cdecl _heapused (size_t *_Used, size_t *_Commit)
 
_CRTIMP intptr_t __cdecl _get_heap_handle (void)
 
static __inline void_MarkAllocaS (void *_Ptr, unsigned int _Marker)
 
static __inline void __cdecl _freea (void *_Memory)
 

Variables

unsigned int _amblksiz
 
_Check_return_ _Ret_maybenull_ _In_ size_t _SizeOfElements
 
_Check_return_ _Ret_maybenull_ _In_ size_t _NewSize
 
_Check_return_ _Ret_maybenull_ _In_ size_t _Count
 
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Size
 
_Check_return_ _Ret_maybenull_ _In_ size_t _Alignment
 
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Offset
 

Macro Definition Documentation

◆ _ALLOCA_S_HEAP_MARKER

#define _ALLOCA_S_HEAP_MARKER   0xDDDD

Definition at line 309 of file malloc.h.

◆ _ALLOCA_S_STACK_MARKER

#define _ALLOCA_S_STACK_MARKER   0xCCCC

Definition at line 308 of file malloc.h.

◆ _ALLOCA_S_THRESHOLD

#define _ALLOCA_S_THRESHOLD   1024

Definition at line 307 of file malloc.h.

◆ _CRT_ALLOCATION_DEFINED

#define _CRT_ALLOCATION_DEFINED

Definition at line 67 of file malloc.h.

◆ _FREEA_INLINE

#define _FREEA_INLINE

Definition at line 335 of file malloc.h.

◆ _FREEENTRY

#define _FREEENTRY   0

Definition at line 36 of file malloc.h.

◆ _HEAP_MAXREQ

#define _HEAP_MAXREQ   0xFFFFFFE0

Definition at line 24 of file malloc.h.

◆ _HEAPBADBEGIN

#define _HEAPBADBEGIN   (-3)

Definition at line 30 of file malloc.h.

◆ _HEAPBADNODE

#define _HEAPBADNODE   (-4)

Definition at line 31 of file malloc.h.

◆ _HEAPBADPTR

#define _HEAPBADPTR   (-6)

Definition at line 33 of file malloc.h.

◆ _HEAPEMPTY

#define _HEAPEMPTY   (-1)

Definition at line 28 of file malloc.h.

◆ _HEAPEND

#define _HEAPEND   (-5)

Definition at line 32 of file malloc.h.

◆ _HEAPINFO_DEFINED

#define _HEAPINFO_DEFINED

Definition at line 40 of file malloc.h.

◆ _HEAPOK

#define _HEAPOK   (-2)

Definition at line 29 of file malloc.h.

◆ _malloca

#define _malloca (   size)
Value:
((((size) + _ALLOCA_S_MARKER_SIZE) <= _ALLOCA_S_THRESHOLD) ? \
_MarkAllocaS(_alloca((size) + _ALLOCA_S_MARKER_SIZE),_ALLOCA_S_STACK_MARKER) : \
_MarkAllocaS(malloc((size) + _ALLOCA_S_MARKER_SIZE),_ALLOCA_S_HEAP_MARKER))
#define malloc
Definition: debug_ros.c:4
GLsizeiptr size
Definition: glext.h:5919
#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

Definition at line 330 of file malloc.h.

◆ _MAX_WAIT_MALLOC_CRT

#define _MAX_WAIT_MALLOC_CRT   60000

Definition at line 200 of file malloc.h.

◆ _mm_free

#define _mm_free (   a)    _aligned_free(a)

Definition at line 63 of file malloc.h.

◆ _mm_malloc

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

Definition at line 64 of file malloc.h.

◆ _MM_MALLOC_H_INCLUDED

#define _MM_MALLOC_H_INCLUDED

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER within this package.

Definition at line 14 of file malloc.h.

◆ _USEDENTRY

#define _USEDENTRY   1

Definition at line 37 of file malloc.h.

◆ alloca

#define alloca   _alloca

Definition at line 357 of file malloc.h.

Typedef Documentation

◆ _HEAPINFO

Function Documentation

◆ _freea()

static __inline void __cdecl _freea ( void _Memory)
static

Definition at line 339 of file malloc.h.

339 {
340 unsigned int _Marker;
341 if(_Memory) {
342 _Memory = (char*)_Memory - _ALLOCA_S_MARKER_SIZE;
343 _Marker = *(unsigned int *)_Memory;
344 if(_Marker==_ALLOCA_S_HEAP_MARKER) {
345 free(_Memory);
346 }
347#ifdef _ASSERTE
348 else if(_Marker!=_ALLOCA_S_STACK_MARKER) {
349 _ASSERTE(("Corrupted pointer passed to _freea",0));
350 }
351#endif
352 }
353 }
#define _ASSERTE(expr)
Definition: crtdbg.h:113
#define free
Definition: debug_ros.c:5

◆ _get_amblksiz()

_CRTIMP errno_t __cdecl _get_amblksiz ( _Out_ size_t _Value)

◆ _get_heap_handle()

_CRTIMP intptr_t __cdecl _get_heap_handle ( void  )

Definition at line 381 of file heap.c.

382{
383 return (MSVCRT_intptr_t)heap;
384}
long MSVCRT_intptr_t
Definition: msvcrt.h:68
static HANDLE heap
Definition: heap.c:65

◆ _get_sbh_threshold()

_Check_return_ _CRTIMP size_t __cdecl _get_sbh_threshold ( void  )

Definition at line 542 of file heap.c.

543{
545}
static MSVCRT_size_t MSVCRT_sbh_threshold
Definition: heap.c:75

Referenced by test_sbheap().

◆ _heapadd()

_Check_return_ _CRTIMP int __cdecl _heapadd ( _In_ void _Memory,
_In_ size_t  _Size 
)

◆ _heapchk()

Definition at line 123 of file malloc.c.

124{
125 if (!HeapValidate(GetProcessHeap(), 0, NULL))
126 return -1;
127 return 0;
128}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
BOOL WINAPI HeapValidate(HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem)
Definition: heapmem.c:156

Referenced by _heapset().

◆ _heapmin()

Definition at line 133 of file malloc.c.

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

◆ _heapset()

_CRTIMP int __cdecl _heapset ( _In_ unsigned int  _Fill)

◆ _heapused()

_CRTIMP size_t __cdecl _heapused ( size_t _Used,
size_t _Commit 
)

Definition at line 45 of file stubs.c.

46{
48 return( 0 );
49}
#define UNIMPLEMENTED
Definition: stubs.c:6

◆ _heapwalk()

_CRTIMP int __cdecl _heapwalk ( _Inout_ _HEAPINFO _EntryInfo)

◆ _MarkAllocaS()

static __inline void * _MarkAllocaS ( void _Ptr,
unsigned int  _Marker 
)
static

Definition at line 320 of file malloc.h.

320 {
321 if(_Ptr) {
322 *((unsigned int*)_Ptr) = _Marker;
323 _Ptr = (char*)_Ptr + _ALLOCA_S_MARKER_SIZE;
324 }
325 return _Ptr;
326 }

◆ _msize()

_Check_return_ _CRTIMP size_t __cdecl _msize ( _In_ void _Memory)

◆ _Post_writable_byte_size_() [1/4]

_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ ( _Count _Size)

◆ _Post_writable_byte_size_() [2/4]

_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ ( _NewSize  )

◆ _Post_writable_byte_size_() [3/4]

_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ ( _NumOfElements *  _SizeOfElements)

◆ _Post_writable_byte_size_() [4/4]

_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ ( _Size  )

◆ _resetstkoflw()

_CRTIMP 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

◆ _set_amblksiz()

_CRTIMP errno_t __cdecl _set_amblksiz ( _In_ size_t  _Value)

◆ _set_malloc_crt_max_wait()

_CRTIMP unsigned long __cdecl _set_malloc_crt_max_wait ( _In_ unsigned long  _NewValue)

◆ _set_sbh_threshold()

_CRTIMP int __cdecl _set_sbh_threshold ( _In_ size_t  _NewValue)

Referenced by test_sbheap().

◆ free()

Variable Documentation

◆ _Alignment

Definition at line 139 of file malloc.h.

◆ _amblksiz

unsigned int _amblksiz
extern

◆ _Count

Definition at line 108 of file malloc.h.

◆ _NewSize

Definition at line 98 of file malloc.h.

◆ _Offset

◆ _Size

Definition at line 109 of file malloc.h.

Referenced by __lg().

◆ _SizeOfElements

Definition at line 76 of file malloc.h.