summaryrefslogtreecommitdiffhomepage
path: root/Public/Kits/System.Core/Heap.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Public/Kits/System.Core/Heap.cxx')
-rw-r--r--Public/Kits/System.Core/Heap.cxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/Public/Kits/System.Core/Heap.cxx b/Public/Kits/System.Core/Heap.cxx
new file mode 100644
index 00000000..c7401aad
--- /dev/null
+++ b/Public/Kits/System.Core/Heap.cxx
@@ -0,0 +1,38 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <System.Core/Heap.hxx>
+#include <System.Core/System.Core.hxx>
+
+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);
+} \ No newline at end of file