summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/KernelKit/HeapMgr.inl
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-29 10:51:53 +0200
committerGitHub <noreply@github.com>2025-05-29 10:51:53 +0200
commit5c0bb7ee7b1b0fee02cc179fb21f4c57a61d6c2d (patch)
treecb17577bcdc9714c97a84ce417a075117097f146 /dev/kernel/KernelKit/HeapMgr.inl
parentd608230b1350b064ceb01e6572519b108f6139b0 (diff)
parent3167f59dbb401d6a79b1524537e04218baf49ee3 (diff)
Merge pull request #32 from nekernel-org/dev
0.0.2e3
Diffstat (limited to 'dev/kernel/KernelKit/HeapMgr.inl')
-rw-r--r--dev/kernel/KernelKit/HeapMgr.inl35
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