SDL_zero(3)

πŸ’– SDL_zero β€” bestie, we're zeroing this memory πŸ’–

okay so welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_zero from the good people at Simple Directmedia Layer. She clears an object's memory to zero, and honestly? iconic behaviour. πŸŽ€


✨ NAME ✨

SDL_zero β€” Clear an object's memory to zero. 🧼


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))

Like, look at her. One line. Gorgeous. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea, bestie: this is a wrapper over SDL_memset that handles calculating the object size for you. Which means there's no chance of copy/paste errors, and the code is just... cleaner. It's giving "I do my own homework and I do it correctly." ✨

IMPORTANT GIRL MATH ALERT: this requires an object, not a pointer to an object, and nor an array. It wants the actual thing itself, sitting right there in front of you. Not a reference to it. Not a whole lineup of them. Just the object. Periodt. πŸ’€

πŸŽ€ MACRO PARAMETERS πŸŽ€

  • x β€” the object to clear. That's it. That's the whole parameter list. She's low maintenance. 🫢

⭐ THREAD SAFETY ⭐

It is safe to call this macro from any thread. No cap. Go off, multithreaded queen. πŸ‘‘


🌈 AVAILABILITY 🌈

This macro has been available since SDL 3.2.0. So if you're on anything older... no she's not there yet, sorry bestie. 😭


πŸ’œ SEE ALSO πŸ’œ

(the pointer one and the array one β€” the whole friend group fr fr πŸ“)


Simple Directmedia Layer made this, SDL 3.4.18 is the version we're vibing on, and that's the whole page. Mwah. πŸ§šβœ¨πŸ’–

πŸ“¦ where this page comes from