MeVisLab Toolbox Reference
ml::Memory Class Reference

#include <mlMemory.h>

Classes

struct  Deleter
 A custom delete that can be used in std::unique_ptr and std::shared_ptr. More...

Static Public Member Functions

static void * allocateMemory (MLuint numBytes, MLMemoryErrorHandling handleFailure)
static void * reallocateMemory (void *ptr, MLuint numBytes, MLMemoryErrorHandling handleFailure)
static void freeMemory (void *ptr)
static void * duplicateMemory (const void *ptr, MLuint numBytes, MLMemoryErrorHandling handleFailure)
static char * duplicateString (const char *str, MLMemoryErrorHandling handleFailure)

Detailed Description

Basic memory management class for the ML. See mlDataTypes.h for enum MLMemoryErrorHandling.

Definition at line 29 of file mlMemory.h.

Member Function Documentation

◆ allocateMemory()

void * ml::Memory::allocateMemory ( MLuint numBytes,
MLMemoryErrorHandling handleFailure )
staticnodiscard

Allocates a memory block of numByts. Should be used instead of normal malloc if code is written that uses/bases on the ML. For handleFailure see MLMemoryErrorHandling.

Referenced by ml::TKernel< MLfloat >::setKernel().

◆ duplicateMemory()

void * ml::Memory::duplicateMemory ( const void * ptr,
MLuint numBytes,
MLMemoryErrorHandling handleFailure )
staticnodiscard

Copies the memory pointed to by ptr of size numBytes in a newly allocated buffer that must be freed by the caller with freeMemory(). For handleFailure see MLMemoryErrorHandling. If ptr is passed as NULL, NULL is returned without any error handling.

◆ duplicateString()

char * ml::Memory::duplicateString ( const char * str,
MLMemoryErrorHandling handleFailure )
staticnodiscard

Copies the passed NULL-terminated string str in a newly allocated buffer that must be freed by the caller with freeMemory(). For handleFailure see MLMemoryErrorHandling.

Referenced by ml::TKernel< KDATATYPE >::setKernel().

◆ freeMemory()

void ml::Memory::freeMemory ( void * ptr)
static

Free function to be used instead of free if code is written that uses/bases on the ML. NULL pointers may be passed safely; they are simply ignored.

Referenced by ml::TKernel< KDATATYPE >::setKernel(), and ml::TKernel< MLfloat >::setKernel().

◆ reallocateMemory()

void * ml::Memory::reallocateMemory ( void * ptr,
MLuint numBytes,
MLMemoryErrorHandling handleFailure )
staticnodiscard

The memory block pointed to by ptr is resized and copied so that it has at least numBytes. Should be used instead of normal realloc if code is written that uses/bases on the ML. For handleFailure see MLMemoryErrorHandling.


The documentation for this class was generated from the following file: