diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-19 21:01:12 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-19 21:01:12 +0100 |
| commit | de413aa50bac1342e4ac8c7a66697ea3b551c2e4 (patch) | |
| tree | eef86262346e556f276727da3d8175ead9c6ff1d /Public/Kits/System.Core/HeapImpl.cxx | |
| parent | af7bb25934e8f6781cb7b34ef345ef9af723a2ff (diff) | |
Kernel(Secret): Major commit.
- Extensive cleanup of the code, and kernel improvements.
- The System API has been reworked to be better designed.
What is needed now:
- AHCI disk driver.
- HCFS/NewFS driver.
- EPM layout implementation.
- Separate bootloader and kernel.
Diffstat (limited to 'Public/Kits/System.Core/HeapImpl.cxx')
| -rw-r--r-- | Public/Kits/System.Core/HeapImpl.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Public/Kits/System.Core/HeapImpl.cxx b/Public/Kits/System.Core/HeapImpl.cxx new file mode 100644 index 00000000..f41c868f --- /dev/null +++ b/Public/Kits/System.Core/HeapImpl.cxx @@ -0,0 +1,41 @@ +/* ------------------------------------------- + + 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() { 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 |
