10 #ifndef ALLOC_TYPE_HPP
11 #define ALLOC_TYPE_HPP
44 if (this->count <
count) {
46 this->buffer = MallocT<T>(
count);
61 if (this->count <
count) {
63 this->buffer = CallocT<T>(
count);
66 memset(this->buffer, 0,
sizeof(T) *
count);
96 inline void *
operator new(
size_t size) {
return CallocT<uint8_t>(size); }
103 inline void *
operator new[](
size_t size) {
return CallocT<uint8_t>(size); }
109 inline void operator delete(
void *ptr) {
free(ptr); }
115 inline void operator delete[](
void *ptr) {
free(ptr); }
Functions related to the allocation of memory.
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
ReusableBuffer()
Create a new buffer.
T * ZeroAllocate(size_t count)
Get buffer of at least count times T with zeroed memory.
const T * GetBuffer() const
Get the currently allocated buffer.
T * buffer
The real data buffer.
size_t count
Number of T elements in the buffer.
T * Allocate(size_t count)
Get buffer of at least count times T.
~ReusableBuffer()
Clear the buffer.
Base class that provides memory initialization on dynamically created objects.
void free(const void *ptr)
Version of the standard free that accepts const pointers.