AAlloc is a custom memory allocator developed as a C library. It provides a convenient way to allocate and deallocate memory regions of custom sizes.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
To build this project, you'll need:
- A C/C++ compiler
- CMake
Here are the steps to build the project:
-
Clone the repository:
git clone https://github.com/yourusername/aalloc.git cd aalloc
-
Create a
dist
directory and navigate into it:mkdir dist cd dist
-
Build the project:
make
When you'll run the make
command, tests will be executed, but you can run them only:
make test
AAlloc provides the following API to allocate and deallocate memory:
Create a new Arena.
Allocates a region of memory from the specified region. Returns a pointer to the allocated memory.
Frees the specified region of memory.
#include "aalloc.h"
// Create Arena
Arena *a = new_arena();
// Allocate memory and use the returned pointer
// to store your data.
void *ptr_a = alloc_arena(a, 512);
void *ptr_b = alloc_arena(a, 512);
void *ptr_c = alloc_arena(a, 512);
// Free the whole region.
free_arena(a);
a = nullptr;
If you have suggestions for how AAlloc could be improved, or want to report a bug, open an issue! Contributions of all kinds are welcomed!
MIT © Tony Gorez