SDL_CompareA...AtomicPointer(3)
π SDL_CompareA...AtomicPointer(3) π
okay so bestie, this page is from the SDL3 FUNCTIONS manual, and the function is SDL_CompareAndSwapAtomicPointer. it's giving "swap the pointer only if it still matches the old value" energy, and honestly? iconic. periodt. β¨
π NAME π
SDL_CompareAndSwapAtomicPointer β set a pointer to a new value if it is currently an old value. slay. π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_atomic.h>
bool SDL_CompareAndSwapAtomicPointer(void **a, void *oldval, void *newval);
πΈ DESCRIPTION πΈ
okay so, huge note from the original, and I am quoting it exactly because it matters:
Note: If you don't know what this function is for, you shouldn't use it!
like... if this isn't already your main character function, maybe don't touch it? no shade, just a vibe check. π
π FUNCTION PARAMETERS π
aβ a pointer to a pointer. yes, a pointer to a pointer, we love layers.oldvalβ the old pointer value.newvalβ the new pointer value.
β RETURN VALUE β
Returns true if the pointer was set, false otherwise. that's it, that's the tea. π
π₯ THREAD SAFETY π₯
It is safe to call this function from any thread. yes bestie, any thread. no cap. π«Ά
π AVAILABILITY π
This function is available since SDL 3.2.0. obsessed with that. π
π§ SEE ALSO π§
iykyk, go read those next. fr fr. π
okay bye bestie!! this page came from Simple Directmedia Layer, version SDL 3.4.18 β and the footer has no date listed, so that's the whole mystery. 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