Skip to content
modkitv0.2

memory.h

#include <modkit/memory.h>8 functions

Memory allocation with optional Tracy profiling.

Provides tracked memory allocation functions that report to Tracy profiler when MODKIT_HAS_PROFILER is enabled. Use these for allocations you want to monitor in Tracy's Memory panel.

Functions

mk_callocfunction

void * mk_calloc(size_t count, size_t size)

Allocate zeroed memory with Tracy tracking.

ParameterTypeDescription
countsize_tNumber of elements
sizesize_tSize of each element

Returns Pointer to allocated memory, or NULL on failure

mk_freefunction

void mk_free(void *ptr)

Free memory with Tracy tracking.

ParameterTypeDescription
ptrvoid *Pointer to free (NULL is safe)

mk_mallocfunction

void * mk_malloc(size_t size)

Allocate memory with Tracy tracking.

ParameterTypeDescription
sizesize_tNumber of bytes to allocate

Returns Pointer to allocated memory, or NULL on failure

mk_memory_get_alloc_countfunction

size_t mk_memory_get_alloc_count(void)

Get total allocation count.

Returns Number of allocations made via mk_* functions

mk_memory_get_peakfunction

size_t mk_memory_get_peak(void)

Get peak tracked memory usage.

Returns Peak bytes allocated via mk_* functions

mk_memory_get_usagefunction

size_t mk_memory_get_usage(void)

Get current tracked memory usage.

Returns Total bytes currently allocated via mk_* functions

mk_reallocfunction

void * mk_realloc(void *ptr, size_t size)

Reallocate memory with Tracy tracking.

ParameterTypeDescription
ptrvoid *Pointer to existing allocation (or NULL)
sizesize_tNew size in bytes

Returns Pointer to reallocated memory, or NULL on failure

mk_strdupfunction

char * mk_strdup(const char *str)

Duplicate a string with Tracy tracking.

ParameterTypeDescription
strconst char *String to duplicate

Returns New string (must be freed with mk_free), or NULL on failure