Memory buffer class to encapsulate and manage raw contiguously memory.
More...
#include <memorybuffer.h>
Memory buffer class to encapsulate and manage raw contiguously memory.
◆ MemoryBuffer() [1/3]
| a_util::memory::MemoryBuffer::MemoryBuffer |
( |
std::size_t | initial_size | ) |
|
CTOR with initial size of the buffer (first allocates, then zero-initializes the buffer)
- Parameters
-
| [in] | initial_size | The initial buffer size |
◆ MemoryBuffer() [2/3]
| a_util::memory::MemoryBuffer::MemoryBuffer |
( |
void * | buffer, |
|
|
std::size_t | size ) |
CTOR attaching to memory from a an already existing buffer (non-owning!)
- Parameters
-
| [in] | buffer | Pointer to the pre-allocated buffer that gets attached (non-owning!) |
| [in] | size | Size of the memory buffer |
◆ MemoryBuffer() [3/3]
| a_util::memory::MemoryBuffer::MemoryBuffer |
( |
const MemoryBuffer & | other | ) |
|
Copy constructor, always allocating new memory and performing a deep copy.
- Parameters
-
| [in] | other | Other memory buffer object to copy from. |
◆ allocate()
| bool a_util::memory::MemoryBuffer::allocate |
( |
std::size_t | new_size | ) |
|
Allocate and zero-initialize a new memory buffer, freeing or detaching any managed memory
- Parameters
-
| [in] | new_size | The size of the new buffer (a value of zero equals reset()) |
- Returns
true if the allocation succeeded, false otherwise
◆ attach()
| void a_util::memory::MemoryBuffer::attach |
( |
void * | buffer, |
|
|
std::size_t | size ) |
Attach a pre-allocated buffer to the instance (non-owning!)
- Parameters
-
| [in] | buffer | Pointer to the pre-allocated memory buffer |
| [in] | size | Size of the memory buffer |
◆ getPtr()
| void * a_util::memory::MemoryBuffer::getPtr |
( |
| ) |
const |
Get raw pointer to the current buffer
- Returns
- Pointer to managed memory or
nullptr if no memory is managed.
◆ getSize()
| std::size_t a_util::memory::MemoryBuffer::getSize |
( |
| ) |
const |
Get the size of the currently managed memory.
- Returns
- Size of the currently managed memory.
◆ operator=()
Assignment operator, always allocating new memory and performing a deep copy.
- Parameters
-
| [in] | other | Other memory buffer object to copy from. |
- Returns
*this
◆ reset()
| void a_util::memory::MemoryBuffer::reset |
( |
| ) |
|
Reset the memory (freeing or detaching any managed memory)
◆ swap()
| void a_util::memory::MemoryBuffer::swap |
( |
MemoryBuffer & | other | ) |
|
Swap content of this object with other
- Parameters
-
| [in] | other | Other memory buffer object to swap the content with. |
The documentation for this class was generated from the following file: