![]() |
UtilsLite
Utilities for C++ programming
|
Class for fixed-size memory allocation of objects. More...
#include <Malloc.hxx>
Public Types | |
using | valueType = T |
Type alias for the type of objects managed by this allocator. | |
Public Member Functions | |
MallocFixed (MallocFixed< T, mem_size > const &)=delete | |
Copy constructor is deleted. | |
MallocFixed< T, mem_size > const & | operator= (MallocFixed< T, mem_size > const &) const =delete |
Assignment operator is deleted. | |
MallocFixed (string name) | |
Constructor. | |
~MallocFixed ()=default | |
Destructor. | |
void | free () |
Free memory without deallocating the pointer. | |
T * | operator() (size_t sz) |
Allocate memory for sz objects and return the pointer. | |
void | pop (size_t sz) |
Free memory for sz objects. | |
bool | is_empty () const |
Check if the memory is fully allocated. | |
Static Public Member Functions | |
static size_t | size () |
Get the number of allocated objects. | |
Class for fixed-size memory allocation of objects.
This class manages memory for a fixed number of objects of type T
.
T | The type of objects to allocate. |
mem_size | The fixed size of memory to allocate. |
using Utils::MallocFixed< T, mem_size >::valueType = T |
Type alias for the type of objects managed by this allocator.
|
delete |
Copy constructor is deleted.
|
inlineexplicit |
Constructor.
name | A string identifier for the allocated memory block. |
|
default |
Destructor.
|
inline |
Free memory without deallocating the pointer.
|
inline |
Check if the memory is fully allocated.
true
if all memory is allocated, false
otherwise. T * Utils::MallocFixed< T, mem_size >::operator() | ( | size_t | sz | ) |
Allocate memory for sz
objects and return the pointer.
sz | Number of objects to allocate. |
|
delete |
Assignment operator is deleted.
void Utils::MallocFixed< T, mem_size >::pop | ( | size_t | sz | ) |
Free memory for sz
objects.
sz | Number of objects to free. |
|
inlinestatic |
Get the number of allocated objects.