|
HAllocator
A Simple C++ Memory Allocator
|
Memory block management with Red-Black tree based allocator. More...
#include <sys/mman.h>#include <algorithm>#include <cstddef>#include <fstream>#include "RBTreeDriver.hpp"

Go to the source code of this file.
Classes | |
| struct | hh::halloc::MemoryNode |
| Node structure for both Red-Black tree and doubly-linked list. More... | |
| class | hh::halloc::Block |
| Manages a contiguous memory block with RB-tree based allocation. More... | |
Namespaces | |
| namespace | hh |
| namespace | hh::halloc |
Macros | |
| #define | REQUEST_MEMORY_VIA_MMAP(size) mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) |
| Allocates memory from the operating system using mmap. | |
| #define | RELEASE_MEMORY_VIA_MUNMAP(ptr, size) munmap(ptr, size) |
| Releases memory back to the operating system using munmap. | |
| #define | MEMORY_NODE_SIZE sizeof(MemoryNode) |
| Size of the MemoryNode metadata structure. | |
Memory block management with Red-Black tree based allocator.
This file implements a memory block that uses a Red-Black tree to track free memory regions and provides efficient allocation/deallocation.
| #define MEMORY_NODE_SIZE sizeof(MemoryNode) |
Size of the MemoryNode metadata structure.
| #define RELEASE_MEMORY_VIA_MUNMAP | ( | ptr, | |
| size | |||
| ) | munmap(ptr, size) |
Releases memory back to the operating system using munmap.
| ptr | Pointer to memory to release |
| size | Size in bytes to release |
| #define REQUEST_MEMORY_VIA_MMAP | ( | size | ) | mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) |
Allocates memory from the operating system using mmap.
| size | Size in bytes to allocate |