SDL_TLSDESTRUCTORCALLBACK(3type)
π SDL_TLSDestructorCallback π
okay bestie, welcome to the SDL3 DATATYPES corner of the manual, where we talk about SDL_TLSDestructorCallback β yes that's a whole mouthful, no I will not be pronouncing it out loud, and yes it is genuinely iconic once you get what it does π«Ά
β¨ NAME β¨
SDL_TLSDestructorCallback β the callback used to cleanup data passed to SDL_SetTLS.
like. it's the lil cleanup crew. the one that shows up when a thread dips out and makes sure nothing's left lying around π§Ήβ¨
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_thread.h>
typedef void (SDLCALL *SDL_TLSDestructorCallback)(void *value);
that's it. that's the whole thing. a function pointer type, slaying quietly π
π¦ DESCRIPTION π¦
so here's the vibe: this callback gets called when a thread exits, and its whole job is to let an app free any resources it was holding onto. it's giving responsible bestie energy β you made a mess in that thread, and now somebody's gotta clean it up before the lights go out π
it's literally just there so you don't leak stuff when a thread says bye. periodt.
π FUNCTION PARAMETERS π
valueβ a pointer previously handed toSDL_SetTLS. like, the exact same pointer you gave it. it comes back to you one last time so you can free it π
π AVAILABILITY π
this datatype is available since SDL 3.2.0. so if you're on anything older than that... bestie, it's not there, sorry π
π SEE ALSO π
ngl, if you're reading this because you're writing a destructor and you're not sure when it fires: it fires on thread exit. that's the whole moment. don't overthink it π
okay that's the page!! go forth and free your memory!! ππβ¨
β written with love for Simple Directmedia Layer, SDL 3.4.18. mwah. π ππ¦
π¦ 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