# ReusableBuffer< T > Class Template Reference

A reusable buffer that can be used for places that temporary allocate a bit of memory and do that very often, or for places where static memory is allocated that might need to be reallocated sometimes. More...

`#include <alloc_type.hpp>`

## Public Member Functions

| ReusableBuffer ()
| Create a new buffer.
| ~ReusableBuffer ()
| Clear the buffer.
T * | Allocate (size_t count)
| Get buffer of at least count times T.
T * | ZeroAllocate (size_t count)
| Get buffer of at least count times T with zeroed memory.
FORCEINLINE const T * | GetBuffer () const
| Get the currently allocated buffer.

## Private Attributes

T * | buffer
| The real data buffer.
size_t | count
| Number of T elements in the buffer.

## Detailed Description

### template<typename T>
class ReusableBuffer< T >

A reusable buffer that can be used for places that temporary allocate a bit of memory and do that very often, or for places where static memory is allocated that might need to be reallocated sometimes.

Every time Allocate or ZeroAllocate is called previous results of both functions will become invalid.

Definition at line 89 of file alloc_type.hpp.

## Member Function Documentation

template<typename T>

T* ReusableBuffer< T >::Allocate | ( | size_t | count | ) | `[inline]`

Get buffer of at least count times T.

Note:
  the buffer might be bigger
  calling this function invalidates any previous buffers given

Parameters:

  | count | the minimum buffer size

Returns:
  the buffer

Definition at line 107 of file alloc_type.hpp.

Referenced by Blitter_8bppOptimized::Encode().

template<typename T>

FORCEINLINE const T* ReusableBuffer< T >::GetBuffer | ( |  | ) | const`[inline]`

Get the currently allocated buffer.

Returns:
  the buffer

Definition at line 140 of file alloc_type.hpp.

template<typename T>

T* ReusableBuffer< T >::ZeroAllocate | ( | size_t | count | ) | `[inline]`

Get buffer of at least count times T with zeroed memory.

Note:
  the buffer might be bigger
  calling this function invalidates any previous buffers given

Parameters:

  | count | the minimum buffer size

Returns:
  the buffer

Definition at line 124 of file alloc_type.hpp.

Referenced by SpriteLoader::Sprite::AllocateData().

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

- src/core/alloc_type.hpp