ReactOS 0.4.16-dev-959-g2ec3a19
malloc_base.cpp File Reference
#include <corecrt_internal.h>
#include <malloc.h>
#include <new.h>
Include dependency graph for malloc_base.cpp:

Go to the source code of this file.

Functions

 __declspec (noinline) _CRTRESTRICT void *__cdecl _malloc_base(size_t const size)
 

Function Documentation

◆ __declspec()

__declspec ( noinline  ) const

Definition at line 23 of file malloc_base.cpp.

24{
25 // Ensure that the requested size is not too large:
27
28 // Ensure we request an allocation of at least one byte:
29 size_t const actual_size = size == 0 ? 1 : size;
30
31 for (;;)
32 {
33 void* const block = HeapAlloc(__acrt_heap, 0, actual_size);
34 if (block)
35 return block;
36
37 // Otherwise, see if we need to call the new handler, and if so call it.
38 // If the new handler fails, just return nullptr:
39 if (_query_new_mode() == 0 || !_callnewh(actual_size))
40 {
41 errno = ENOMEM;
42 return nullptr;
43 }
44
45 // The new handler was successful; try to allocate again...
46 }
47}
#define ENOMEM
Definition: acclib.h:84
_Check_return_ _ACRTIMP int __cdecl _callnewh(_In_ size_t _Size)
#define _HEAP_MAXREQ
Definition: malloc.h:24
#define HeapAlloc
Definition: compat.h:733
GLsizeiptr size
Definition: glext.h:5919
HANDLE __acrt_heap
Definition: heap_handle.cpp:15
#define _VALIDATE_RETURN_NOEXC(expr, errorcode, retexpr)
#define errno
Definition: errno.h:18
_ACRTIMP int __cdecl _query_new_mode(void)
Definition: heap.c:217
static unsigned int block
Definition: xmlmemory.c:101