OpenTTD Source 20250312-master-gcdcc6b491d
|
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 | |
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 of default initialised elements. | |
const T * | GetBuffer () const |
Get the currently allocated buffer. | |
Private Attributes | |
std::vector< T > | 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 22 of file alloc_type.hpp.
|
inline |
Get buffer of at least count times T.
count | the minimum buffer size |
Definition at line 34 of file alloc_type.hpp.
Referenced by LoadNewGRFFileFromFile(), NetworkDrawChatMessage(), and OpenGLSprite::Update().
|
inline |
Get the currently allocated buffer.
Definition at line 58 of file alloc_type.hpp.
Referenced by NetworkUndrawChatMessage(), and OpenGLSprite::Update().
|
inline |
Get buffer of at least count times T of default initialised elements.
count | the minimum buffer size |
Definition at line 47 of file alloc_type.hpp.
Referenced by SpriteLoader::Sprite::AllocateData(), and Blitter_8bppOptimized::Encode().
|
private |
Definition at line 24 of file alloc_type.hpp.