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.
15extern "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.
22{
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.
32extern "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().
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.
49{
50 _ASSERTE(__acrt_heap != nullptr);
51 return __acrt_heap;
52}
#define __cdecl
Definition: accygwin.h:79
#define _ASSERTE(expr)
Definition: crtdbg.h:114
#define GetProcessHeap()
Definition: compat.h:736
bool __cdecl __acrt_uninitialize_heap(bool const)
Definition: heap_handle.cpp:32
HANDLE __acrt_heap
Definition: heap_handle.cpp:15
HANDLE __acrt_getheap()
Definition: heap_handle.cpp:48
bool __cdecl __acrt_initialize_heap()
Definition: heap_handle.cpp:21
intptr_t __cdecl _get_heap_handle()
Definition: heap_handle.cpp:40
int intptr_t
Definition: vcruntime.h:134