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

| ## Public API Reference

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

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

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

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

`#include <csutil/allocator.h>`

List of all members.

## Public Member Functions
T * | Alloc (size_t allocSize)
void | Free (T *mem)
| LocalBufferAllocator (const ExcessAllocator &xalloc)
| LocalBufferAllocator ()
void * | Realloc (void *p, size_t newSize)

## Detailed Description

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

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.

Warning:
  This allocator is designed to work in scenarios where you have at most one block allocated at any time!

  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 120 of file allocator.h.

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

- csutil/allocator.h