NeKernel dev
Loading...
Searching...
No Matches
HeapMgr.inl
Go to the documentation of this file.
1/* ========================================
2
3 Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
4
5======================================== */
6
7#pragma once
8
9#ifndef INC_KERNEL_HEAP_H
10#include <KernelKit/HeapMgr.h>
11#endif // !INC_KERNEL_HEAP_H
12
13namespace Kernel {
17template <typename T, typename... Args>
18inline BOOL mm_new_class(_Input _Output T** cls, _Input Args&&... args) {
19 if (*cls) {
21 return NO;
22 }
23
24 *cls = new T(move(args)...);
25 return *cls;
26}
27
30template <typename T>
32 delete *cls;
33 *cls = nullptr;
34}
35} // namespace Kernel
#define _Output
Definition CompilerHint.h:15
#define _Input
Definition CompilerHint.h:14
#define NO
#define BOOL
: Memory allocation support for the NeKernel.
#define err_global_get()
Definition KPC.h:25
UPS inline definitions.
Definition Device.h:12
void Void
Definition Config.h:87
BOOL mm_new_class(_Input _Output T **cls, _Input Args &&... args)
Allocate C++ class.
Definition HeapMgr.inl:18
constexpr KPCError kErrorInvalidData
Definition KPC.h:56
Args && move(Args &&arg)
Move object.
Definition Config.h:110
Void mm_delete_class(_Input _Output T **cls)
Delete and nullify C++ class.
Definition HeapMgr.inl:31