SDL School

API reference / Files, memory, and strings

SDL_malloc

Function, SDL3

Allocates memory. The memory is not cleared.

Declaration

#include <SDL3/SDL.h>

void * SDL_malloc(size_t size);

Parameters

sizeThe number of bytes.

Return value

A pointer to the memory, or NULL on failure.

Example

Read a file
cards = SDL_malloc((size_t)count_lines(file_text) * sizeof(Card));

See this code run in Read a file. Download the full program (.zip)

Notes

In SDL2

The name is the same.

See also