stumpless 2.2.0
Loading...
Searching...
No Matches
stumpless::MemoryManager Class Reference

Container for memory management functions in Stumpless. More...

#include <MemoryManager.hpp>

Public Member Functions

 MemoryManager (struct stumpless_version *equivalent)
 
 MemoryManager (struct stumpless_version equivalent)
 

Static Public Member Functions

static void FreeAll (void)
 Frees all memory allocated internally, and performs any other necessary cleanup.
 
static void FreeThread (void)
 Frees all memory allocated internally to the calling thread, and performs any other thread-specific cleanup.
 

Public Attributes

struct stumpless_version equivalent
 

Static Public Attributes

static void *(*)(size_t) SetMalloc (void *(*malloc_func)(size_t))
 Sets the function used by Stumpless to allocate memory.
 
static void(*)(void *) SetFree (void(*free_func)(void *))
 Sets the function used by Stumpless to free memory.
 
static void *(*)(void *, size_t) SetRealloc (void *(*realloc_func)(void *, size_t))
 Sets the function used by Stumpless to reallocate memory.
 

Detailed Description

Container for memory management functions in Stumpless.

Constructor & Destructor Documentation

◆ MemoryManager() [1/2]

stumpless::MemoryManager::MemoryManager ( struct stumpless_version * equivalent)

◆ MemoryManager() [2/2]

stumpless::MemoryManager::MemoryManager ( struct stumpless_version equivalent)

Member Function Documentation

◆ FreeAll()

static void stumpless::MemoryManager::FreeAll ( void )
static

Frees all memory allocated internally, and performs any other necessary cleanup.

This function serves as a final exit function, which should be called when an application using the library is preparing to exit or when the library is no longer needed. Before this function is called, all targets must be closed and no pointers to any structs should be retained. Failing to do this will result in undefined behavior.

Calling other functions after a call to this function is acceptable, however execution times may be longer than usual as memory used to cache objects may need to be allocated again. If other functions are called, this function should be called again before exit to ensure a memory leak does not exist.

In a windows environment, this function will call WSACleanup as part of its cleanup.

◆ FreeThread()

static void stumpless::MemoryManager::FreeThread ( void )
static

Frees all memory allocated internally to the calling thread, and performs any other thread-specific cleanup.

This function should be called in any thread that has used stumpless functions before it exits so that caches and other structures can be cleaned up. It is not a substitute for stumpless_free_all, but is called by it and can be left out if stumpless_free_all will be called later in the same thread.

Available since release v2.0.0.

Member Data Documentation

◆ equivalent

struct stumpless_version stumpless::MemoryManager::equivalent

◆ SetFree

void(*)(void *) stumpless::MemoryManager::SetFree(void(*free_func)(void *))
static

Sets the function used by Stumpless to free memory.

Parameters
free_funcA pointer to the memory deallocation function that is desired. This function must have the same signature as the standard library free function, which is the default deallocation function.
Returns
The new deallocation function.

◆ SetMalloc

void *(*)(size_t) stumpless::MemoryManager::SetMalloc(void *(*malloc_func)(size_t))
static

Sets the function used by Stumpless to allocate memory.

Parameters
malloc_funcA pointer to the allocation function that is desired. This function must have the same signature as the standard library malloc function, which is the default allocation function.
Returns
The new allocation function.

◆ SetRealloc

void *(*)(void *, size_t) stumpless::MemoryManager::SetRealloc(void *(*realloc_func)(void *, size_t))
static

Sets the function used by Stumpless to reallocate memory.

Parameters
realloc_funcA pointer to the memory reallocation function that is desired. This function must have the same signature as the standard library realloc function, which is the default reallocation function.
Returns
The new reallocation function.

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