ReactOS
0.4.16-dev-1946-g52006dd
realloc.cpp
Go to the documentation of this file.
1
//
2
// realloc.cpp
3
//
4
// Copyright (c) Microsoft Corporation. All rights reserved.
5
//
6
// Implementation of realloc().
7
//
8
#include <
corecrt_internal.h
>
9
#include <malloc.h>
10
11
// Reallocates a block of memory in the heap.
12
//
13
// This function reallocates the block pointed to by 'block' such that it is
14
// 'size' bytes in size. The new size may be either greater or less than the
15
// original size of the block. The reallocation may result in the block being
16
// moved to a new location in memory. If the block is moved, the contents of
17
// the original block are copied.
18
//
19
// Standard behavior notes:
20
// [1] realloc(nullptr, new_size) is equivalent to malloc(new_size)
21
// [2] realloc(p, 0) is equivalent to free(p), and nullptr is returned
22
// [3] If reallocation fails, the original block is left unchanged
23
//
24
// If 'block' is non-null, it must point to a valid block of memory allocated in
25
// the heap.
26
//
27
// This function supports patching and therefore must be marked noinline.
28
// Both _realloc_dbg and _realloc_base must also be marked noinline
29
// to prevent identical COMDAT folding from substituting calls to realloc
30
// with either other function or vice versa.
31
extern
"C"
_CRT_HYBRIDPATCHABLE
__declspec
(
noinline
)
_CRTRESTRICT
void
*
__cdecl
realloc
(
32
void
*
const
block
,
33
size_t
const
size
34
)
35
{
36
#ifdef _DEBUG
37
return
_realloc_dbg
(
block
,
size
,
_NORMAL_BLOCK
,
nullptr
, 0);
38
#else
39
return
_realloc_base(
block
,
size
);
40
#endif
41
}
__cdecl
#define __cdecl
Definition:
accygwin.h:79
corecrt_internal.h
_CRTRESTRICT
#define _CRTRESTRICT
Definition:
corecrt.h:17
_realloc_dbg
#define _realloc_dbg(p, s, t, f, l)
Definition:
crtdbg.h:206
_NORMAL_BLOCK
#define _NORMAL_BLOCK
Definition:
crtdbg.h:67
realloc
#define realloc
Definition:
debug_ros.c:6
noinline
#define noinline
Definition:
types.h:64
__declspec
void __declspec(noinline) __cdecl _free_base(void *const block)
Definition:
free_base.cpp:98
size
GLsizeiptr size
Definition:
glext.h:5919
_CRT_HYBRIDPATCHABLE
#define _CRT_HYBRIDPATCHABLE
Definition:
corecrt.h:188
block
static unsigned int block
Definition:
xmlmemory.c:101
sdk
lib
ucrt
heap
realloc.cpp
Generated on Thu Dec 4 2025 06:16:18 for ReactOS by
1.9.6