Zen C++ Libraries
Zero-dependency re-usable components for C++
Loading...
Searching...
No Matches
bump_ptr_pool.hpp File Reference

Implementation of a bump-pointer allocator. More...

#include <cstddef>
#include <cstring>
#include <list>
#include <memory>
#include <new>
#include "zen/config.hpp"
#include "zen/math.hpp"
#include "zen/alloc.hpp"

Go to the source code of this file.

Classes

class  bump_ptr_pool
 A chunk of memory for storing variable-width objects which get destroyed all at once. More...
class  growing_bump_ptr_pool
 A growing collection of memory chunks for storing variable-width objects which get destroyed all at once. More...

Macros

#define ZEN_DEFAULT_POOL_CHUNK_SIZE   65536
#define ZEN_DEFAULT_GROWING_BUMP_PTR_POOL_MIN_SIZE   4084

Detailed Description

Implementation of a bump-pointer allocator.

This header defines bump_ptr_pool, a kind of allocator that moves a pointer to the right each time a new allocation is done.

#include <iostream>
#include "zen/alloc.hpp"
int main() {
zen::bump_ptr_pool p;
int* one_in_pool = zen::construct<int>(p, 42);
std::cerr << "42 == " << *one_in_pool << "\n";
}
Generic tools and utilities for using and defining allocators.
Implementation of a bump-pointer allocator.