![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
A class for managing memory segments within a memory allocation. More...
#include <MemoryAllocation.h>
Public Member Functions | |
| MemoryAllocation (void *ptr, size_t size, size_t alignment=1) | |
| template<class T > | |
| std::pair< T *, size_t > | Alloc (size_t size) |
| std::pair< void *, size_t > | Alloc (size_t size) |
| std::pair< void *, size_t > | AllocLargestSegment () |
| Returns the largest free segment. More... | |
| template<class T > | |
| void | Free (const std::pair< T *, size_t > &segment) |
| Frees a previously returned segment. More... | |
| void | Free (const std::pair< void *, size_t > &segment) |
| Frees a previously returned segment. More... | |
| size_t | MaxUsed () const |
| Returns the peak memory usage in bytes. More... | |
| size_t | Alignment () const |
| Returns the alignment in bytes. More... | |
| const std::vector< std::pair< void *, size_t > > & | FreeSegments () const |
| Returns the list of free segments. More... | |
| void | PrintFreeSegments () const |
| Prints all free segments. Meant for debugging. More... | |
Static Public Member Functions | |
| template<class T > | |
| static void | PrintSegment (const std::pair< T *, size_t > &s) |
| Prints the segment. Meant for debugging. More... | |
A class for managing memory segments within a memory allocation.
Definition at line 21 of file MemoryAllocation.h.
|
inline |
Creates a MemoryAllocation object that manages memory segments within a memory allocation.
| ptr | Pointer to the beginning of the memory. |
| size | Size of the memory. |
| alignment | The alignment for returned segments. |
Definition at line 30 of file MemoryAllocation.h.
References size.
|
inline |
Returns the alignment in bytes.
Definition at line 148 of file MemoryAllocation.h.
|
inline |
Returns a memory segment with size for type T. Returns the pointer and the size in number of elements T. May return the pair (nullptr,0) if the allocation is not possible.
Definition at line 48 of file MemoryAllocation.h.
References size.
Referenced by AllocLargestSegment().
|
inline |
Returns a memory segment with size in bytes. May return the pair (nullptr,0) if the allocation is not possible.
Definition at line 55 of file MemoryAllocation.h.
References size.
|
inline |
Returns the largest free segment.
Definition at line 75 of file MemoryAllocation.h.
|
inline |
Frees a previously returned segment.
Definition at line 85 of file MemoryAllocation.h.
References size.
|
inline |
Frees a previously returned segment.
Definition at line 93 of file MemoryAllocation.h.
References count.
|
inline |
Returns the list of free segments.
Definition at line 151 of file MemoryAllocation.h.
|
inline |
Returns the peak memory usage in bytes.
Definition at line 145 of file MemoryAllocation.h.
|
inline |
Prints all free segments. Meant for debugging.
Definition at line 163 of file MemoryAllocation.h.
References PrintSegment().
|
inlinestatic |
Prints the segment. Meant for debugging.
Definition at line 157 of file MemoryAllocation.h.
Referenced by PrintFreeSegments().