ralloc is a custom memory allocator built in C with x86-64 assembly integrations, designed as a learning project to understand how memory allocators work at a low level.
- Pure C and x86-64 assembly implementation
- Linux
mmapandmunmapsyscalls for memory management - Header-embedded metadata for allocation tracking
- Magic number validation for detecting memory corruption
git clone https://github.com/Mal1koRe1ss/ralloc.git
cd ralloc
sudo mv ./src/ralloc.h /usr/include/Now, you can include the allocator in your projects with:
#include <ralloc.h>You only need to compile with ralloc.c.
git clone https://github.com/Mal1koRe1ss/ralloc.git
cp ./src/ralloc.h ./src/ralloc.c /your/project/directory/Include the header in your code:
#include "ralloc.h"Compile your project with ralloc.c:
gcc your_program.c ralloc.c -o your_programNote for MSVC Users: Replace
__asm__with__asmin the source code for MSVC compatibility.
void *rallocmem(size_t size): Allocatessizebytes of memory.void rfree(void *ptr): Frees memory previously allocated byrallocmem.
- Proper alignment handling
-
rreallocmem()implementation -
rcallocmem()implementation
- Free list management
- Size classes for reduced fragmentation
- Boundary tags for overflow detection
- Allocation statistics tracking
- Thread safety (mutex support)
- Comprehensive test suite
- Benchmarking against system allocator