SDL_malloc_func(3type)
π SDL_malloc_func π
okay bestie, welcome to the SDL_malloc_func page, part of the SDL3 datatypes era, and honestly? this one's short and sweet and kinda iconic for it. no cap.
β¨ NAME β¨
SDL_malloc_func β it's a callback, and its whole job is to be the thing that actually implements SDL_malloc(). like, SDL's malloc is calling you up and being like "hey, you handle the memory, i trust you." main character energy fr fr. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
typedef void *(SDLCALL *SDL_malloc_func)(size_t size);
look at that little typedef. precious. it takes a size_t size and hands back a void *, and there's a SDLCALL in there because calling conventions are a thing we respect in this house. π
π¦ DESCRIPTION π¦
SDL is gonna be super considerate about this, okay? SDL will always ensure that the passed size is greater than 0. so you never have to sit there wondering "what if they ask me to allocate zero bytes" β they won't. the size is always gonna be a positive number. that's the vibe. β¨
π FUNCTION PARAMETERS π
sizeβ the size to allocate. that's it, that's the whole thing. the amount of memory you're being asked to hand over. π
π RETURN VALUE π
you return a pointer to the allocated memory. and if the allocation flops? you return NULL. no drama, just NULL, and SDL will deal with it. π
π₯ THREAD SAFETY π₯
It should be safe to call this callback from any thread. so like, any thread can roll up and call you, and that's fine and expected. go off, multithreading queen. π
β AVAILABILITY β
this datatype has been around since SDL 3.2.0. so if you're on 3.2.0 or later, you're golden. β¨
π SEE ALSO π
go read those too, bestie, they're all part of the same memory-functions friend group. iykyk. π«Ά
lowkey reminder: this is just a typedef, not a function you call directly β it's the shape of a callback you'd write yourself and hand to SDL. don't @ me. π
and that's the page!! brought to you by Simple Directmedia Layer, from the SDL 3.4.18 era, and this lil entry is SDL_malloc_func(3type). mwah, go allocate something cute. ππ§πΈ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms