diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-10 15:41:08 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-10 15:41:08 +0100 |
| commit | 5468ca71a59c9e24c1d392554e8f97f0c1705394 (patch) | |
| tree | 1e8af47da852d4ad02a2ea48a967694c7bfc19c3 /Public/Kits/System.Core/HeapAPI.cxx | |
| parent | 94d7585ae766d777f41d07b1a98051d12a6a0256 (diff) | |
Kernel: Reworked StorageKit to add AHCI support.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Public/Kits/System.Core/HeapAPI.cxx')
| -rw-r--r-- | Public/Kits/System.Core/HeapAPI.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Public/Kits/System.Core/HeapAPI.cxx b/Public/Kits/System.Core/HeapAPI.cxx new file mode 100644 index 00000000..f59e0b1b --- /dev/null +++ b/Public/Kits/System.Core/HeapAPI.cxx @@ -0,0 +1,34 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <System.Core/HeapAPI.hxx> +#include <System.Core/HcHeapAPI.h> + +using namespace HCore; + +STATIC HcObjectPtr kObjectHeap; + +HHeap* HHeap::Shared() noexcept { + static HHeap* heap = nullptr; + + if (!heap) { + heap = new HHeap(); + kObjectHeap = HcGetProcessHeap(); + } + + return heap; +} + +void HHeap::Delete(HHeapPtr me) noexcept { HcFreeProcessHeap(kObjectHeap, me); } + +SizeT HHeap::Size(HHeapPtr me) noexcept { return HcProcessHeapSize(kObjectHeap, me); } + +HHeapPtr HHeap::New(const SizeT &sz, const Int32 flags) { + SizeT _sz = sz; + if (!_sz) ++_sz; + + return HcAllocateProcessHeap(kObjectHeap, _sz, flags); +}
\ No newline at end of file |
