SDL_free(3)

πŸ’– SDL_free(3) β€” the SDL3 FUNCTIONS girlies' guide to letting go πŸ’–

okay bestie, so you know how every time you ask SDL_malloc for memory it's like "sure babe, here's a pointer"? well SDL_free is the other half of that situationship. it's the breakup function. the "we had a good run but I need my RAM back" moment. and she's part of the SDL3 FUNCTIONS crew, so you know she's iconic. πŸŽ€


✨ NAME ✨

SDL_free β€” Free allocated memory.

like, actually release it. hand it back. no take-backs.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

void SDL_free(void *mem);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: after you call this, that pointer is no longer valid and you literally cannot dereference it anymore. it's done. it's over. it's giving expired. πŸ™ˆ

do not go poking at it afterwards, bestie, that's a one-way ticket to undefined behaviour city and we do not stan.

but β€” and this is the cute part β€” if mem is NULL, this function does absolutely nothing. no crash, no drama, no tears. it just vibes. πŸ’…


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • mem β€” a pointer to allocated memory, or NULL. that's it, that's the whole girl. if it's NULL she's unbothered, if it's a real pointer she's taking it out back and freeing it.

🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread. any. thread. no cap. call her from your main thread, call her from a worker, call her from the backrooms, she does not care. 🫢


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. if you're on anything older, sorry babe, she wasn't born yet. 😭


πŸ‘‘ SEE ALSO πŸ‘‘

the whole memory-management friend group, they're all linked, they all text each other:


⚠️ lowkey the most important thing on this whole page: once you free it, that pointer is dead to you. do not dereference it. do not pass it around. do not think about it. let her go. πŸ•ŠοΈ

and that's the whole page, bestie, no notes. this lil masterpiece lives in SDL 3.4.18 from the Simple Directmedia Layer girlies, dated SDL_free(3) β€” mwah, slay, periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from