ReactOS 0.4.16-dev-2110-ge3521eb
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 HeapAlloc
Definition: compat.h:733
int CDECL _query_new_mode(void)
Definition: heap.c:196
int CDECL _callnewh(size_t size)
Definition: heap.c:131
#define ENOMEM
Definition: errno.h:35
#define errno
Definition: errno.h:120
GLsizeiptr size
Definition: glext.h:5919
HANDLE __acrt_heap
Definition: heap_handle.cpp:15
#define _VALIDATE_RETURN_NOEXC(expr, errorcode, retexpr)
#define _HEAP_MAXREQ
Definition: malloc.h:24
static unsigned int block
Definition: xmlmemory.c:101