#include <logger.h>
|
| virtual void | logGetSegment (void *segment, std::size_t segmentSize)=0 |
| virtual void | logFreeSegment (void *segment, std::size_t segmentSize)=0 |
| virtual void | logTrimEmptySegments ()=0 |
| virtual void | logAllocation (void *userPtr, std::size_t userSize, MemAllocType_et allocType)=0 |
| virtual void | logReallocation (void *userPtr, std::size_t oldUserSize, std::size_t newUserSize)=0 |
| virtual void | logDeallocation (void *userPtr, std::size_t userSize)=0 |
| virtual void | logError (void *userPtr, MemError_et error, const char *message, const char *file=__FILE__, int line=__LINE__)=0 |
A MemLogger logs memory allocation, deallocation, and errors.
This class here is merely used to define the functions needed to implement a MemLogger.
◆ logAllocation()
| virtual void cookmem::MemLogger::logAllocation |
( |
void * | userPtr, |
|
|
std::size_t | userSize, |
|
|
MemAllocType_et | allocType ) |
|
pure virtual |
Log the memory allocation.
- Parameters
-
| userPtr | the user pointer allocated, or nullptr if the allocation failed. |
| userSize | the size of the allocation, as getSize () reports it: the requested size if the exact size is stored, and otherwise the requested size rounded up to the alignment. If the allocation failed, the requested size. |
| allocType | the type of the allocation. |
◆ logDeallocation()
| virtual void cookmem::MemLogger::logDeallocation |
( |
void * | userPtr, |
|
|
std::size_t | userSize ) |
|
pure virtual |
Log the memory deallocation.
- Parameters
-
| userPtr | the user pointer allocated. |
| userSize | the size of the allocation, as getSize () reports it, which is the size its allocation was logged with. |
◆ logError()
| virtual void cookmem::MemLogger::logError |
( |
void * | userPtr, |
|
|
MemError_et | error, |
|
|
const char * | message, |
|
|
const char * | file = __FILE__, |
|
|
int | line = __LINE__ ) |
|
pure virtual |
Log an error that the memory pool detected: a double free (MEM_ERROR_DOUBLE_FREE), overwritten padding bytes (MEM_ERROR_PADDING), or an invalid padding size when the pool is created (MEM_ERROR_GENERAL). The loggers of CookMem throw Exception with the same error, message, file and line. A logger may record the error first, or throw its own exception. It is not safe to go on after an error, so if this function returns, the pool throws Exception itself.
- Parameters
-
| userPtr | the user pointer that had the error, or nullptr. |
| error | the type of the error encountered. |
| message | a description of the error. |
| file | the source file where the error was detected. |
| line | the line number where the error was detected. |
◆ logFreeSegment()
| virtual void cookmem::MemLogger::logFreeSegment |
( |
void * | segment, |
|
|
std::size_t | segmentSize ) |
|
pure virtual |
Log the memory segment release.
- Parameters
-
| segment | the segment released. |
| segmentSize | the segment size. |
◆ logGetSegment()
| virtual void cookmem::MemLogger::logGetSegment |
( |
void * | segment, |
|
|
std::size_t | segmentSize ) |
|
pure virtual |
Log the memory segment allocation.
- Parameters
-
| segment | the segment obtained. |
| segmentSize | the segment size. |
◆ logReallocation()
| virtual void cookmem::MemLogger::logReallocation |
( |
void * | userPtr, |
|
|
std::size_t | oldUserSize, |
|
|
std::size_t | newUserSize ) |
|
pure virtual |
Log a reallocation in place, which grows or shrinks an allocation without moving it. A reallocation that moves the memory is logged as an allocation and a deallocation instead.
- Parameters
-
| userPtr | the user pointer, which does not change. |
| oldUserSize | the size before, as getSize () reported it. |
| newUserSize | the size after, as getSize () reports it. |
◆ logTrimEmptySegments()
| virtual void cookmem::MemLogger::logTrimEmptySegments |
( |
| ) |
|
|
pure virtual |
Log a pool empty-segment trimming pass.
The documentation for this class was generated from the following file: