CS::Memory::LocalBufferAllocator< T, N, ExcessAllocator, SingleAllocation > Class Template Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

CS::Memory::LocalBufferAllocator< T, N, ExcessAllocator, SingleAllocation > Class Template Reference

An allocator with a small local buffer. More...

`#include <csutil/allocator.h>`

List of all members.

## Detailed Description

### template<typename T, size_t N, class ExcessAllocator = AllocatorMalloc, bool SingleAllocation = false>
class CS::Memory::LocalBufferAllocator< T, N, ExcessAllocator, SingleAllocation >

An allocator with a small local buffer.

If the data fits into the local buffer (which is set up to holds `N` elements of type `T`), a memory allocation from the heap is saved. Thus, if you have lots of arrays with a relatively small, well known size you can gain some performance by using this allocator. `SingleAllocation` specifies whether no more than a single block is allocated from the allocator at any time. Using that option saves (albeit a miniscule amount of) memory, but obviously is only safe when it's known that the single allocation constraint is satisfied (such as allocators for csArray<>s).

Warning:
  The pointer returned may point into the instance data; be careful when moving that around - an earlier allocated pointer may suddenly become invalid!

Remarks:
  This means that if you use this allocator with an array, and you nest that into another array, you MUST use csSafeCopyArrayElementHandler for the nesting array!

Definition at line 152 of file allocator.h.

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

- csutil/allocator.h