---
name: "SDL_realloc"
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_realloc"
---

# SDL\_realloc(3)

Change the size of allocated memory.

## NAME

SDL\_realloc - Change the size of allocated memory.

## HEADER FILE

Defined in SDL3/SDL\_stdinc.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**void \* SDL\_realloc(void \*mem, size\_t size);**

## DESCRIPTION

The memory returned by this function must be freed with

**SDL\_free** ().

If **size** is 0, it will be set to 1. Note that this is unlike some other C runtime **realloc** implementations, which may treat **realloc(mem,**0) the same way as **free(mem)** .

If **mem** is NULL, the behavior of this function is equivalent to

**SDL\_malloc** (). Otherwise, the function can have one of three possible outcomes:

• If it returns the same pointer as **mem** , it means that **mem** was resized\
   in place without freeing.

• If it returns a different non-NULL pointer, it means that **mem** was freed\
   and cannot be dereferenced anymore.

• If it returns NULL (indicating failure), then **mem** will remain valid and\
   must still be freed with  **SDL\_free** ().

If the allocation is successfully resized, the returned pointer is guaranteed to be aligned to either the *fundamental alignment* ( **alignof(max\_align\_t)** in C11 and later) or **2** *sizeof(void* ) , whichever is smaller.

## FUNCTION PARAMETERS

- *mem*

  a pointer to allocated memory to reallocate, or NULL.

- *size*

  the new size of the memory.

## RETURN VALUE

Returns a pointer to the newly allocated memory, or NULL if allocation failed.

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_free**(3)](/SDL_free/3.md), **•**(3), [**SDL\_malloc**(3)](/SDL_malloc/3.md), **•**(3), [**SDL\_calloc**(3)](/SDL_calloc/3.md)
