summaryrefslogtreecommitdiffhomepage
path: root/Public/Kits/System.Core/Heap.cxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-19 22:50:16 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-19 22:50:16 +0100
commita0f82d57976648c5bfcf165b2e304d2a4c8fb0c7 (patch)
treec24cd3e850a9fc47b352ac8efa50a93b28388925 /Public/Kits/System.Core/Heap.cxx
parentde413aa50bac1342e4ac8c7a66697ea3b551c2e4 (diff)
Kernel:Secret: Fix String class.
Improve kernel APIs.
Diffstat (limited to 'Public/Kits/System.Core/Heap.cxx')
-rw-r--r--Public/Kits/System.Core/Heap.cxx42
1 files changed, 42 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..4dfd34e4
--- /dev/null
+++ b/Public/Kits/System.Core/Heap.cxx
@@ -0,0 +1,42 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <System.Core/Heap.hxx>
+#include <System.Core/System.Core.hxx>
+
+using namespace System;
+
+/// @brief Shared instance of the heap.
+/// @return
+Heap* Heap::Shared() noexcept {
+ static Heap* heap = nullptr;
+
+ if (!heap) {
+ heap = new Heap();
+ }
+
+ return heap;
+}
+
+Heap::Heap() { }
+Heap::~Heap() { delete this; }
+
+void Heap::Delete(HeapPtr me) noexcept {
+ CA_MUST_PASS(me);
+ HcFreeProcessHeap(kInstanceObject, me);
+}
+
+SizeT Heap::Size(HeapPtr me) noexcept {
+ CA_MUST_PASS(me);
+ return HcProcessHeapSize(kInstanceObject, me);
+}
+
+HeapPtr Heap::New(const SizeT& sz, const Int32 flags) {
+ SizeT _sz = sz;
+ if (!_sz) ++_sz;
+
+ return HcAllocateProcessHeap(kInstanceObject, _sz, flags);
+} \ No newline at end of file