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 82 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 100 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 117 of file alloc_type.hpp.

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

template<typename T>
FORCEINLINE const T* ReusableBuffer< T >::GetBuffer (  )  const [inline]

Get the currently allocated buffer.

Returns:
the buffer

Definition at line 133 of file alloc_type.hpp.


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

Generated on Mon Dec 14 21:00:29 2009 for OpenTTD by  doxygen 1.5.6