---
name: "SDL_malloc"
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_malloc"
---

# SDL\_malloc(3)

Allocate uninitialized memory.

## NAME

SDL\_malloc - Allocate uninitialized memory.

## HEADER FILE

Defined in SDL3/SDL\_stdinc.h

## SYNOPSIS

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

**void \* SDL\_malloc(size\_t size);**

## DESCRIPTION

The allocated memory returned by this function must be freed with

**SDL\_free** ().

If **size** is 0, it will be set to 1.

If the allocation is successful, 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. Use

**SDL\_aligned\_alloc** () if you need to allocate memory aligned to an alignment greater than this guarantee.

## FUNCTION PARAMETERS

- *size*

  the size to allocate.

## RETURN VALUE

Returns a pointer to the 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\_calloc**(3)](/SDL_calloc/3.md), **•**(3), [**SDL\_realloc**(3)](/SDL_realloc/3.md), **•**(3), [**SDL\_aligned\_alloc**(3)](/SDL_aligned_alloc/3.md)
