---
name: "SDL_SetMemoryFunctions"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_SetMemoryFunctions"
---

# SDL\_SetMemoryFunctions(3)

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

## 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

- *malloc\_func*

  custom malloc function.

- *calloc\_func*

  custom calloc function.

- *realloc\_func*

  custom realloc function.

- *free\_func*

  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.2.0.

## SEE ALSO

**•**(3), [**SDL\_GetMemoryFunctions**(3)](/SDL_GetMemoryFunctions/3.md), **•**(3), [**SDL\_GetOriginalMemoryFunctions**(3)](/SDL_GetOriginalMemoryFunctions/3.md)
