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