SDL_DestroyRWLock(3)

✨ SDL_DestroyRWLock β€” the glow-down for your rwlock πŸ’…

okay so bestie, we're in the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_DestroyRWLock. it's giving cleanup era. let's get into it 🫢


🌸 NAME 🌸

SDL_DestroyRWLock β€” destroy a read/write lock that you made with SDL_CreateRWLock(). yeah. that one. the lock. it's time πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_mutex.h>

void SDL_DestroyRWLock(SDL_RWLock *rwlock);

like, that's the whole thing. one function, one pointer, zero drama. iconic honestly πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

okay so listen. this function must be called on any read/write lock that is no longer needed. MUST. not "should", not "whenever you feel like it", not "next semester". fr fr. 😀

and here's why, bestie: failure to destroy a rwlock will result in a system memory or resource leak. like, your program is just gonna be out here holding onto stuff it doesn't need anymore. it's giving hoarder energy and we are NOT doing that πŸ™ˆ

now, the vibe check on safety:

  • it is safe to destroy a rwlock that is unlocked βœ…
  • it is not safe to attempt to destroy a locked rwlock ❌

and if you do try to destroy a locked rwlock anyway? it may result in undefined behavior depending on the platform. like, undefined. nobody knows what happens. the platform decides. it's chaos. do not pass go. do not collect $200. just don't πŸ’€

lowkey the whole rule is: unlock it first, then destroy it. that's the order. that's the vibe. periodt.

πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • rwlock β€” the rwlock to destroy. that's the one. the read/write lock. hand it over and let it go πŸ•ŠοΈ

πŸ’œ THREAD SAFETY πŸ’œ

good news bestie!! it is safe to call this function from any thread. literally any of them. go wild. slay 🌈


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on something older, sorry babe, no SDL_DestroyRWLock for you 😭


πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_CreateRWLock(3) β€” the one that started it all. you can't destroy what you never created, iykyk πŸ’«

and that's the page!! written by the Simple Directmedia Layer girlies, from SDL 3.4.18, dated with the SDL_DestroyRWLock(3) energy we all know and love. go forth, unlock your locks, free your memory, and stay leak-free bestie πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from