Sierra Toolkit Version of the Day
|fixed_allocator (const char *=EASTL_FIXED_POOL_DEFAULT_NAME)|
|fixed_allocator (const fixed_allocator &)|
|fixed_allocator &||operator= (const fixed_allocator &)|
|void *||allocate (size_t, int=0)|
|void *||allocate (size_t n, size_t, size_t, int flags=0)|
|void||deallocate (void *p, size_t)|
|const char *||get_name () const|
|void||set_name (const char *)|
Implements an allocator which allocates a single fixed size where the size, alignment, and memory used for the pool is defined at runtime by the user. This is different from fixed containers such as fixed_list whereby the size and alignment are determined at compile time and the memory is directly built into the container's member data.
If the pool's memory is exhausted or was never initialized, the allocate function returns NULL. Consider the fixed_allocator_with_overflow class as an alternative in order to deal with this situation.
This class requires the user to call container.get_allocator().init() after constructing the container. There currently isn't a way to construct the container with the initialization parameters, though with some effort such a thing could probably be made possible. It's not as simple as it might first seem, due to the non-copyable nature of fixed allocators. A side effect of this limitation is that you cannot copy-construct a container using fixed_allocators.
Another side-effect is that you cannot swap two containers using a fixed_allocator, as a swap requires temporary memory allocated by an equivalent allocator, and such a thing cannot be done implicitly. A workaround for the swap limitation is that you can implement your own swap whereby you provide an explicitly created temporary object.
Note: Be careful to set the allocator's node size to the size of the container node and not the size of the contained object. Note that the example code below uses IntListNode.
Example usage: typedef eastl::list<int, fixed_allocator> IntList; typedef IntList::node_type IntListNode;
IntListNode buffer; IntList intList; intList.get_allocator().init(buffer, sizeof(buffer), sizeof(IntListNode), __alignof(IntListNode));
|eastl::fixed_allocator::fixed_allocator||(||const char *|| = ||)||
|eastl::fixed_allocator::fixed_allocator||(||const fixed_allocator &||)||
Copy constructor. The user usually will need to call init() after constructing via this constructor. By their nature, fixed-allocators cannot be copied in any useful way, as by their nature the user must manually initialize them.
|void eastl::fixed_allocator::deallocate||(||void *||p,|