amino
Lightweight Robot Utility Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
aa_mem_region Struct Reference

Data Structure for Region-Based memory allocation. More...

#include <mem.h>

Public Attributes

uint8_t * head
 pointer to first free element of top chunk
 
struct aa_mem_region_nodenode
 linked list of chunks
 

Detailed Description

Data Structure for Region-Based memory allocation.

Memory regions provide fast allocation of individual objects and fast deallocation of all objects in the region and of all objects allocated after some given object. It is not possible to deallocate only a single arbitrary object from the region.

This provides two benefits over malloc/free. First, as long as the requested allocation can be fulfilled from the memory available in the region, allocation and deallocation require only a pointer increment or decrement. Second, there is no need to store any metadata for each individual allocation resulting in some space savings, expecially for small objects.

This implementation pre-allocates chunks of memory and fulfills individual requests from those chunks. If the request cannot be satisfied from the currently available chunk, this implemention will malloc() another chunk and add it to the region in a linked list. When objects are deallocated via a release or a pop, chunks are merged into one, possibly requiring several calls to free() followed by a single malloc of a new, larger chunk.

Definition at line 198 of file mem.h.


The documentation for this struct was generated from the following file: