Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gubnik/arena_allocator

A very simple C++ arena allocator
https://github.com/gubnik/arena_allocator

allocator arena-allocator cplusplus cpp educational educational-project memory memory-management

Last synced: about 1 month ago
JSON representation

A very simple C++ arena allocator

Awesome Lists containing this project

README

        

# Arena allocator

A very simple C++ arena allocator using POSIX mmap.
It is unfit for commercial usage and should be only used for
educational purposes.

## Install
```bash
sudo make install
```

## Test
To run a test program, run
```bash
make test
```

## Example
```c++
#include

int main (int argc, char ** argv)
{
arena::allocator Lifetime = arena::allocator::create(400);
int * Buf_1 = Lifetime.allocate(120);
int * Buf_2 = Lifetime.allocate(80);
int * Buf_3 = Lifetime.allocate(200);
// Further allocation will yield null as arena's memory is over
// Arena's memory is deallocated when it goes out of scope
}
```