Reactos
1//
2// malloc.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Implementation of malloc().
7//
8#include <corecrt_internal.h>
9#include <malloc.h>
10
11
12
13// Allocates a block of memory of size 'size' bytes in the heap. If allocation
14// fails, nullptr is returned.
15//
16// This function supports patching and therefore must be marked noinline.
17// Both _malloc_dbg and _malloc_base must also be marked noinline
18// to prevent identical COMDAT folding from substituting calls to malloc
19// with either other function or vice versa.
20extern "C" _CRT_HYBRIDPATCHABLE __declspec(noinline) _CRTRESTRICT void* __cdecl malloc(size_t const size)
21{
22 #ifdef _DEBUG
23 return _malloc_dbg(size, _NORMAL_BLOCK, nullptr, 0);
24 #else
25 return _malloc_base(size);
26 #endif
27}