libarena
Arena memory management library
Loading...
Searching...
No Matches
libarena

arena

An Arena memory manager

Build Status Doxygen Status Clang-format status

Table of Contents

  • Overview
  • Features
  • Building
  • Testing
  • Library Documentation
  • Further Reading
  • Bugs
  • License

Overview

This is an Arena memory manager with basic bookkeeping and support for basic memory management functions (malloc, calloc, realloc, memcpy, and free). Arena memory managers are useful for short-lived data, such as game state information, ASTs, and other use-cases where the needed size is predictable and speed is important. Arenas can also be easily dumped for debugging.

Features

  • Bookkeeping: Block metadata is internally stored. When a block is freed, that memory may be used by a newly allocated block.
  • Tagging: Each block can have an assigned integer tag. It is possible to find a block by its tag or free all blocks with a given tag.

Bookkeeping can be disabled for better performance, but tags will not work. When an Arena is initialized with managed set to false, whenever malloc or calloc is called, an internal pointer will simply be incremented, and blocks will not be managed internally.

Building

Requirements

  • Cmake 3.31.6 or higher
  • A C99 compatible compiler (e.g. clang, gcc)

Linux / macOS

# build library
cmake -S . -B build
cmake --build build
# install
cmake --install build

Testing

Linux / macOS

git submodule update
cmake -S . -B build -DTEST=ON
cmake --build build
cd build
ctest --verbose

Documentation

Library documentation is available here.

Further Reading

Bugs

If you find a bug, submit an issue, PR, or email me with a description and/or patch.

License

Copyright (c) 2025-2026 Ben O'Neill ben@o.nosp@m.neil.nosp@m.l.sh. This work is released under the terms of the MIT License. See [LICENSE](LICENSE) for the license terms.