ReactOS  0.4.13-dev-257-gfabbd7c
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 _STATIC_ASSERT(expr)   extern char (*static_assert(void)) [(expr) ? 1 : -1]
 
#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 313 of file malloc.h.

◆ _ALLOCA_S_STACK_MARKER

#define _ALLOCA_S_STACK_MARKER   0xCCCC

Definition at line 312 of file malloc.h.

◆ _ALLOCA_S_THRESHOLD

#define _ALLOCA_S_THRESHOLD   1024

Definition at line 311 of file malloc.h.

◆ _CRT_ALLOCATION_DEFINED

#define _CRT_ALLOCATION_DEFINED

Definition at line 71 of file malloc.h.

◆ _FREEA_INLINE

#define _FREEA_INLINE

Definition at line 339 of file malloc.h.

◆ _FREEENTRY

#define _FREEENTRY   0

Definition at line 40 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 34 of file malloc.h.

◆ _HEAPBADNODE

#define _HEAPBADNODE   (-4)

Definition at line 35 of file malloc.h.

◆ _HEAPBADPTR

#define _HEAPBADPTR   (-6)

Definition at line 37 of file malloc.h.

◆ _HEAPEMPTY

#define _HEAPEMPTY   (-1)

Definition at line 32 of file malloc.h.

◆ _HEAPEND

#define _HEAPEND   (-5)

Definition at line 36 of file malloc.h.

◆ _HEAPINFO_DEFINED

#define _HEAPINFO_DEFINED

Definition at line 44 of file malloc.h.

◆ _HEAPOK

#define _HEAPOK   (-2)

Definition at line 33 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 _ALLOCA_S_STACK_MARKER
Definition: malloc.h:312
#define _ALLOCA_S_HEAP_MARKER
Definition: malloc.h:313
GLsizeiptr size
Definition: glext.h:5919
#define _ALLOCA_S_THRESHOLD
Definition: malloc.h:311
static __inline void * _MarkAllocaS(void *_Ptr, unsigned int _Marker)
Definition: malloc.h:324
#define malloc
Definition: debug_ros.c:4

Definition at line 334 of file malloc.h.

◆ _MAX_WAIT_MALLOC_CRT

#define _MAX_WAIT_MALLOC_CRT   60000

Definition at line 204 of file malloc.h.

◆ _mm_free

#define _mm_free (   a)    _aligned_free(a)

Definition at line 67 of file malloc.h.

◆ _mm_malloc

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

Definition at line 68 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.

◆ _STATIC_ASSERT

#define _STATIC_ASSERT (   expr)    extern char (*static_assert(void)) [(expr) ? 1 : -1]

Definition at line 28 of file malloc.h.

◆ _USEDENTRY

#define _USEDENTRY   1

Definition at line 41 of file malloc.h.

◆ alloca

#define alloca   _alloca

Definition at line 361 of file malloc.h.

Typedef Documentation

◆ _HEAPINFO

Function Documentation

◆ _freea()

static __inline void __cdecl _freea ( void _Memory)
static

Definition at line 343 of file malloc.h.

343  {
344  unsigned int _Marker;
345  if(_Memory) {
346  _Memory = (char*)_Memory - _ALLOCA_S_MARKER_SIZE;
347  _Marker = *(unsigned int *)_Memory;
348  if(_Marker==_ALLOCA_S_HEAP_MARKER) {
349  free(_Memory);
350  }
351 #ifdef _ASSERTE
352  else if(_Marker!=_ALLOCA_S_STACK_MARKER) {
353  _ASSERTE(("Corrupted pointer passed to _freea",0));
354  }
355 #endif
356  }
357  }
void __cdecl free(_Pre_maybenull_ _Post_invalid_ void *_Memory)
#define _ALLOCA_S_STACK_MARKER
Definition: malloc.h:312
#define _ALLOCA_S_HEAP_MARKER
Definition: malloc.h:313
#define _ASSERTE(expr)
Definition: crtdbg.h:105

◆ _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 269 of file heap.c.

270 {
271  return (intptr_t)GetProcessHeap();
272 }
#define GetProcessHeap()
Definition: compat.h:395
int intptr_t
Definition: crtdefs.h:283

◆ _get_sbh_threshold()

_Check_return_ _CRTIMP size_t __cdecl _get_sbh_threshold ( void  )

Definition at line 338 of file heap.c.

339 {
340  return MSVCRT_sbh_threshold;
341 }
static size_t MSVCRT_sbh_threshold
Definition: heap.c:47

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 }
BOOL WINAPI HeapValidate(HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem)
Definition: heapmem.c:156
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395

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 }
#define GetProcessHeap()
Definition: compat.h:395
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 44 of file stubs.c.

45 {
47  return( 0 );
48 }
#define UNIMPLEMENTED
Definition: stubs.c:5

◆ _heapwalk()

_CRTIMP int __cdecl _heapwalk ( _Inout_ _HEAPINFO _EntryInfo)

◆ _MarkAllocaS()

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

Definition at line 324 of file malloc.h.

324  {
325  if(_Ptr) {
326  *((unsigned int*)_Ptr) = _Marker;
327  _Ptr = (char*)_Ptr + _ALLOCA_S_MARKER_SIZE;
328  }
329  return _Ptr;
330  }

◆ _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_ ( _NumOfElements *  _SizeOfElements)

◆ _Post_writable_byte_size_() [2/4]

_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ ( _Size  )

◆ _Post_writable_byte_size_() [3/4]

_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ ( _NewSize  )

◆ _Post_writable_byte_size_() [4/4]

_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_ ( _Count _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 }
#define PAGE_GUARD
Definition: nt_native.h:1310
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:144
#define PAGE_READWRITE
Definition: nt_native.h:1304

◆ _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)

◆ free()

Referenced by _freea().

Variable Documentation

◆ _Alignment

Definition at line 143 of file malloc.h.

◆ _amblksiz

unsigned int _amblksiz

◆ _Count

Definition at line 112 of file malloc.h.

◆ _NewSize

Definition at line 102 of file malloc.h.

◆ _Offset

◆ _Size

Definition at line 112 of file malloc.h.

Referenced by __lg().

◆ _SizeOfElements

Definition at line 80 of file malloc.h.