SDL_AtomicDecRef(3)
π SDL_AtomicDecRef(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we talk about SDL_AtomicDecRef β the little macro that goes down so your refcount can go out. π¦
β¨ NAME β¨
SDL_AtomicDecRef β decrement an atomic variable used as a reference count. that's it, that's the whole job, and she does it flawlessly. π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_atomic.h>
#define SDL_AtomicDecRef(a) (SDL_AddAtomicInt(a, -1) == 1)
look at her. one line. no notes. π₯
β¨ DESCRIPTION β¨
so basically this macro does a little minus one on your atomic reference count, atomically, so you don't have to stress about races. iconic behaviour, honestly. π
Note: If you don't know what this macro is for, you shouldn't use it!
fr fr. this is not a "let me just try it and see" situation. if refcounting isn't already your whole personality, step away from the macro, bestie. π
β¨ MACRO PARAMETERS β¨
aβ a pointer to anSDL_AtomicIntto decrement. yes, a pointer, hand her the address, she'll handle the rest. π«Ά
β¨ RETURN VALUE β¨
Returns true if the variable reached zero after decrementing, false otherwise. so like β if it hit zero, that's your cue that you were the last one holding on and the cleanup is yours to do. main character moment. πΈ
β¨ THREAD SAFETY β¨
It is safe to call this macro from any thread. any. thread. go wild, she's built different. π
β¨ AVAILABILITY β¨
This macro is available since SDL 3.2.0. so if you're on something older... bestie. π
β¨ SEE ALSO β¨
SDL_AtomicIncRef(3)β the other half of the duo, the one who adds. they're a matching set, don't split them up. π
and that's the whole page, no cap. mwah. π
this has been a Simple Directmedia Layer production, brought to you by SDL 3.4.18 β ty for reading, ily, go fix your refcounts. πβ¨
π¦ 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