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