3 ms·
This is called arena allocation, and there are many implementations of the concept. For example, the C++ Protocol Buffers library has an Arena class, which is
by alexhutcheson 6y ago
This is called arena allocation, and there are many implementations of the concept.
For example, the C++ Protocol Buffers library has an Arena class, which is documented here: https://developers.google.com/protocol-buffers/docs/reference/arenas https://developers.google.com/protocol-buffers/docs/referenc...
The EA STL has fixed_allocator, which implements a similar concept while exposing more low-level details in the API: https://github.com/electronicarts/EASTL/blob/master/include/EASTL/fixed_allocator.h https://github.com/electronicarts/EASTL/blob/master/include/...
- sgtnoodle 6y agoI'd describe it more as a pool or block allocator. An arena allocator is specifically optimized for incremental allocation and then bulk deallocation (the entire arena is freed at once). The example code instead appears to create a context of a number of fixed sized blocks. Because of the fixed size, the allocator can make a lot of simplifying assumptions and generally achieve constant time algorithmic complexity, while allowing for individual allocations to be freed and reused.