diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-23 11:12:31 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-23 11:13:38 +0200 |
| commit | 54a0f4c49d9bfb955174c87dae2f442d7f5a8b25 (patch) | |
| tree | ad59d31c9444fcfc6d5f0da7b17c8843710e6014 /dev/kernel/KernelKit/HeapMgr.inl | |
| parent | fc67c4af554189c941c811486a0b2b21aa3f54ea (diff) | |
feat!(Kernel): Improvements on the BitMapMgr, HTS, and UPS.
other:
- Add ZXD header file.
- Reworking AMD64 interrupts.
- Improved HTS's design implementation.
- Improved UPS's balancing implementation.
breaking changes:
- Rename MemoryMgr to HeapMgr.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/KernelKit/HeapMgr.inl')
| -rw-r--r-- | dev/kernel/KernelKit/HeapMgr.inl | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/dev/kernel/KernelKit/HeapMgr.inl b/dev/kernel/KernelKit/HeapMgr.inl new file mode 100644 index 00000000..6371012e --- /dev/null +++ b/dev/kernel/KernelKit/HeapMgr.inl @@ -0,0 +1,35 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#ifndef INC_KERNEL_HEAP_H +#include <KernelKit/HeapMgr.h> +#endif // !INC_KERNEL_HEAP_H + +namespace Kernel { +/// @brief Allocate C++ class. +/// @param cls The class to allocate. +/// @param args The args to pass. +template <typename T, typename... Args> +inline BOOL mm_new_class(_Input _Output T** cls, _Input Args&&... args) { + if (*cls) { + err_global_get() = Kernel::kErrorInvalidData; + return NO; + } + + *cls = new T(move(args)...); + return *cls; +} + +/// @brief Delete and nullify C++ class. +/// @param cls The class to delete. +template <typename T> +inline Void mm_delete_class(_Input _Output T** cls) { + delete *cls; + *cls = nullptr; +} +} // namespace Kernel
\ No newline at end of file |
