A custom memory allocator implementation in C++. This project implements malloc, free, calloc, and realloc from scratch using only native C++ (no external dependencies). This is done by using the system call sbrk() to manage memory at a low level.
- Implements
malloc,free,calloc, andreallocfrom scratch - Uses native C++ only (no external dependencies)
- Custom memory management strategies
- Test suite with different test types and memory leak detection
- CMake 3.14 or higher
- C++17 compatible compiler
- No external libraries required - 100% native C++
git clone https://github.com/felixnagele/malloc-from-scratch.git
cd malloc-from-scratchsudo apt update && sudo sudo apt install -y build-essential cmake clang-format clang-tidy stracecmake -S . -B buildcmake --build buildgit clone https://github.com/felixnagele/malloc-from-scratch.git && cd malloc-from-scratch && sudo apt update && sudo apt install -y build-essential cmake clang-format clang-tidy strace && cmake -S . -B build && cmake --build buildgcc --version
cmake --version
clang-format --version
clang-tidy --version
strace --versionfind src include tests -name "*.cpp" -o -name "*.h" | xargs clang-format --dry-run -Werrorfind src include tests -name "*.cpp" -o -name "*.h" | xargs clang-format -ifind src tests -name "*.cpp" -exec clang-tidy -p build {} \;Run tests locally:
cmake --build build && ctest --test-dir buildFor detailed test usage with instructions, see tests/README.md.
Tests also run automatically in CI/pipeline here.
See Community Profile for guidelines, license, and support.