SDL_CleanupTLS(3)

πŸ’– SDL_CleanupTLS(3) πŸ’–

ok so bestie, you know how the manual pages have that lil header up top with the name and the manual section? yeah. this one is SDL_CleanupTLS(3), and it lives in the SDL3 FUNCTIONS section of the Simple Directmedia Layer manual. that's the whole vibe. let's get into it 🫢


✨ NAME ✨

SDL_CleanupTLS β€” Cleanup all TLS data for this thread.

like, all of it. this thread's TLS data? gone. cleaned. slayed. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_thread.h>

void SDL_CleanupTLS(void);

no arguments, no return value, just a little void function that takes void and gives you nothing back except peace of mind. it's giving low-maintenance icon πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the situation, and listen up because this one actually matters:

If you are creating your threads outside of SDL and then calling SDL functions, you should call this function before your thread exits, to properly clean up SDL memory.

that's it. that's the whole thing. but the way that it's the whole thing and it's still so important?? 😭

basically: if SDL didn't make the thread, SDL doesn't get to know when the thread is about to dip. so if that thread has been out here touching SDL stuff, you have to be the one to tell SDL "hey bestie, we're wrapping up, let's tidy" β€” and that's what SDL_CleanupTLS is for. call it before your thread exits. it cleans up SDL memory properly. no leaks, no mess, no drama. periodt.

not calling it when you should = SDL memory that never gets cleaned. do with that information what you will πŸ™ˆ

🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. ✨

yes queen, any thread. every thread. all the threads. no vibe check required, no locking ceremony, just call it. 🌈


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.2.0. πŸŽ€

so if you're on anything older than that... babes, it's not there. update. πŸ¦‹


πŸ’œ a lil sign-off πŸ’œ

that's the page, bestie! this one came to you from the Simple Directmedia Layer crew, and it's the SDL 3.4.18 version of the manual β€” so if you're reading this, you're on a build that's already got it. go clean up your threads. i'm obsessed with you for reading a manpage for fun. mwah πŸ’…πŸ’–πŸŒΈ

πŸ“¦ where this page comes from