ReactOS
0.4.16-dev-822-gbcedb53
heap_handle.cpp
Go to the documentation of this file.
1
//
2
// heap_handle.cpp
3
//
4
// Copyright (c) Microsoft Corporation. All rights reserved.
5
//
6
// Defines the global CRT heap handle and initialization/termination functions.
7
//
8
#include <
corecrt_internal.h
>
9
#include <malloc.h>
10
11
12
13
// The CRT heap handle. This global variable is modified only during CRT
14
// startup and CRT shutdown.
15
extern
"C"
{
HANDLE
__acrt_heap
=
nullptr
; }
16
17
18
19
// Initializes the heap. This function must be called during CRT startup, and
20
// must be called before any user code that might use the heap is executed.
21
extern
"C"
bool
__cdecl
__acrt_initialize_heap
()
22
{
23
__acrt_heap
=
GetProcessHeap
();
24
if
(
__acrt_heap
==
nullptr
)
25
return
false
;
26
27
return
true
;
28
}
29
30
// Uninitializes the heap. This function should be called during CRT shutdown,
31
// after any user code that might use the heap has stopped running.
32
extern
"C"
bool
__cdecl
__acrt_uninitialize_heap
(
bool
const
/* terminating */
)
33
{
34
__acrt_heap
=
nullptr
;
35
return
true
;
36
}
37
38
// Gets the HANDLE of the CRT heap. Because the CRT always uses the process
39
// heap, this function always returns the same thing as GetProcessHeap().
40
extern
"C"
intptr_t
__cdecl
_get_heap_handle
()
41
{
42
_ASSERTE
(
__acrt_heap
!=
nullptr
);
43
return
reinterpret_cast<
intptr_t
>
(
__acrt_heap
);
44
}
45
46
// Internal CRT function to get the HANDLE of the CRT heap, that returns a
47
// HANDLE instead of an intptr_t.
48
extern
"C"
HANDLE
__acrt_getheap
()
49
{
50
_ASSERTE
(
__acrt_heap
!=
nullptr
);
51
return
__acrt_heap
;
52
}
__cdecl
#define __cdecl
Definition:
accygwin.h:79
corecrt_internal.h
_ASSERTE
#define _ASSERTE(expr)
Definition:
crtdbg.h:114
GetProcessHeap
#define GetProcessHeap()
Definition:
compat.h:736
__acrt_uninitialize_heap
bool __cdecl __acrt_uninitialize_heap(bool const)
Definition:
heap_handle.cpp:32
__acrt_heap
HANDLE __acrt_heap
Definition:
heap_handle.cpp:15
__acrt_getheap
HANDLE __acrt_getheap()
Definition:
heap_handle.cpp:48
__acrt_initialize_heap
bool __cdecl __acrt_initialize_heap()
Definition:
heap_handle.cpp:21
_get_heap_handle
intptr_t __cdecl _get_heap_handle()
Definition:
heap_handle.cpp:40
void
Definition:
nsiface.idl:2307
intptr_t
int intptr_t
Definition:
vcruntime.h:134
sdk
lib
ucrt
heap
heap_handle.cpp
Generated on Mon Mar 17 2025 06:14:52 for ReactOS by
1.9.6