SDL_DestroyMutex(3)

✨ SDL_DestroyMutex ✨

okay bestie, welcome to the SDL_DestroyMutex(3) page, part of the SDL3 FUNCTIONS lineup πŸ’… this one's a lil short but it's SO important, don't skip it


🌸 NAME 🌸

SDL_DestroyMutex β€” destroy a mutex created with SDL_CreateMutex() πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_mutex.h>

void SDL_DestroyMutex(SDL_Mutex *mutex);

like. that's it. that's the whole call. one line, no return value, no drama πŸŽ€


πŸ’œ DESCRIPTION πŸ’œ

so here's the tea πŸ“ this function must be called on any mutex that is no longer needed. like, it's not optional, bestie. failure to destroy a mutex will result in a system memory or resource leak and nobody wants that energy in their codebase, fr fr 😭

now the important part, and I need you to listen: while it is safe to destroy a mutex that is _unlocked_, it is not safe to attempt to destroy a locked mutex. and what happens if you do? undefined behavior, depending on the platform πŸ’€ like, it might work, it might explode, it's giving chaos, it's giving "why would you do this". so just... don't. unlock it first, queen πŸ‘‘

🫢 tl;dr: destroy your mutexes or leak forever. destroy unlocked mutexes only. locked ones = undefined behavior. periodt.

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • mutex β€” the mutex to destroy. that's the one. the lil guy you're saying goodbye to πŸ₯Ί

🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread ✨ yes you heard that right, any thread, no cap. go off 🧚


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0 πŸ‘‘ so if you're on anything older... bestie. upgrade. it's time πŸ’…


πŸ’– SEE ALSO πŸ’–

  • SDL_CreateMutex(3) β€” the origin story, the birth of your mutex, the before to this after 🌸

and that's the whole page!! short, sweet, iconic, main character energy only πŸ’–

Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_DestroyMutex(3) β€” mwah, go destroy some mutexes responsibly, bestie πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from