---
name: "SDL_calloc"
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_calloc"
---

# SDL\_calloc(3)

Allocate a zero-initialized array.

## NAME

SDL\_calloc - Allocate a zero-initialized array.

## HEADER FILE

Defined in SDL3/SDL\_stdinc.h

## SYNOPSIS

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

**void \* SDL\_calloc(size\_t nmemb, size\_t size);**

## DESCRIPTION

The memory returned by this function must be freed with

**SDL\_free** ().

If either of **nmemb** or **size** is 0, they will both 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.

## FUNCTION PARAMETERS

- *nmemb*

  the number of elements in the array.

- *size*

  the size of each element of the array.

## RETURN VALUE

Returns a pointer to the allocated array, 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\_realloc**(3)](/SDL_realloc/3.md)
