Scroll to navigation

SDL_SetMemoryFunctions(3) SDL3 FUNCTIONS SDL_SetMemoryFunctions(3)

NAME

SDL_SetMemoryFunctions - Replace SDL's memory allocation functions with a custom set.

HEADER FILE

Defined in SDL3/SDL_stdinc.h

SYNOPSIS

#include "SDL3/SDL.h"
bool SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
                                SDL_calloc_func calloc_func,
                                SDL_realloc_func realloc_func,
                                SDL_free_func free_func);

DESCRIPTION

It is not safe to call this function once any allocations have been made, as future calls to SDL_free
will use the new allocator, even if they came from an SDL_malloc
made with the old one!

If used, usually this needs to be the first call made into the SDL library, if not the very first thing done at program startup time.

FUNCTION PARAMETERS

custom malloc function.
custom calloc function.
custom realloc function.
custom free function.

RETURN VALUE

Returns true on success or false on failure; call

SDL_GetError () for more information.

THREAD SAFETY

It is safe to call this function from any thread, but one should not replace the memory functions once any allocations are made!

AVAILABILITY

This function is available since SDL 3.1.3.

SEE ALSO

(3), SDL_GetMemoryFunctions(3), (3), SDL_GetOriginalMemoryFunctions(3)

SDL 3.1.6 Simple Directmedia Layer