SDL School

API reference / Files, memory, and strings

SDL_calloc

Function, SDL3

Allocates memory for an array, and fills it with zeros.

Declaration

#include <SDL3/SDL.h>

void * SDL_calloc(size_t nmemb, size_t size);

Parameters

nmembThe number of elements.
sizeThe size of each element in bytes.

Return value

A pointer to the memory, or NULL on failure.

Example

Hold state in a struct
App *app = SDL_calloc(1, sizeof(App));

See this code run in Hold state in a struct. Download the full program (.zip)

In SDL2

The name is the same.

See also