OpenTTD Source
20241120-master-g6d3adc6169
|
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. More... | |
T * | ZeroAllocate (size_t count) |
Get buffer of at least count times T with zeroed memory. More... | |
const T * | GetBuffer () const |
Get the currently allocated buffer. More... | |
Private Attributes | |
T * | buffer |
The real data buffer. | |
size_t | count |
Number of T elements in the buffer. | |
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 24 of file alloc_type.hpp.
|
inline |
Get buffer of at least count times T.
count | the minimum buffer size |
Definition at line 42 of file alloc_type.hpp.
Referenced by Blitter_8bppOptimized::Encode(), and OpenGLSprite::Update().
|
inline |
|
inline |
Get buffer of at least count times T with zeroed memory.
count | the minimum buffer size |
Definition at line 59 of file alloc_type.hpp.