mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 15:29:18 +00:00
Restructured and rewritten entire codebase
This commit is contained in:
25
core/memory/smart_heap.cpp
Normal file
25
core/memory/smart_heap.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <memory.hpp>
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
SmartHeap::SmartHeap(size_t Size, VirtualMemoryArea *vma)
|
||||
{
|
||||
if (vma)
|
||||
{
|
||||
this->vma = vma;
|
||||
this->Object = vma->RequestPages(TO_PAGES(Size));
|
||||
}
|
||||
else
|
||||
this->Object = kmalloc(Size);
|
||||
this->ObjectSize = Size;
|
||||
memset(this->Object, 0, Size);
|
||||
}
|
||||
|
||||
SmartHeap::~SmartHeap()
|
||||
{
|
||||
if (this->vma)
|
||||
this->vma->FreePages(this->Object, TO_PAGES(this->ObjectSize));
|
||||
else
|
||||
kfree(this->Object);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user