blob: 232b4927118d940746405d4607570777d2bae964 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/* -------------------------------------------
Copyright Mahrouss Logic
------------------------------------------- */
#include <System.Core/HeapAPI.hxx>
#include <System.Core/hcore.h>
using namespace HCore;
using namespace System;
STATIC HcObjectPtr kObjectHeap;
Heap* Heap::Shared() noexcept {
static Heap* heap = nullptr;
if (!heap) {
heap = new Heap();
kObjectHeap = HcGetProcessHeap();
}
return heap;
}
void Heap::Delete(HeapPtr me) noexcept { HcFreeProcessHeap(kObjectHeap, me); }
SizeT Heap::Size(HeapPtr me) noexcept {
CA_MUST_PASS(me);
return HcProcessHeapSize(kObjectHeap, me);
}
HeapPtr Heap::New(const SizeT &sz, const Int32 flags) {
SizeT _sz = sz;
if (!_sz) ++_sz;
return HcAllocateProcessHeap(kObjectHeap, _sz, flags);
}
|