SDL_memset(3)

✨ SDL_memset ✨

okay bestie, so this one's from the SDL3 FUNCTIONS fam, and it's literally the glow-up you need when you wanna paint a chunk of memory one single byte at a time πŸ’…


🌸 NAME 🌸

SDL_memset β€” Initialize all bytes of buffer of memory to a specific value.

like. every single byte. same value. no cap. 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_stdinc.h>

void * SDL_memset(void *dst, int c, size_t len);

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea β˜•: this function will set len bytes, pointed to by dst, to the value specified in c. that's it, that's the whole vibe. she's simple, she's reliable, she's the main character of memory-filling πŸ¦‹

but bestie, listen β€” this is the part where you gotta pay attention, no skipping πŸ™ˆ despite c being an int instead of a char, this only operates on bytes. so c must be a value between 0 and 255, inclusive. that's the range. don't come at her with 256, she will simply not know what to do with you 😭


🌈 FUNCTION PARAMETERS 🌈

  • dst β€” the destination memory region. Must not be NULL. (fr fr, do not do that. that's not a vibe, that's undefined behavior territory πŸ’€)
  • c β€” the byte value to set.
  • len β€” the length, in bytes, to set in dst.

⭐ RETURN VALUE ⭐

Returns dst. she gives you back exactly what you handed her, which is honestly so iconic of her πŸ‘‘


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. go off, multithreaded queen 🌸✨


πŸ”₯ AVAILABILITY πŸ”₯

This function is available since SDL 3.2.0. so if you're on anything older... bestie, upgrade. iykyk πŸ’…


not me writing a whole manpage about filling memory with one byte... and meaning every word of it πŸ’œ

mwah πŸ’‹ that's the page! brought to you by Simple Directmedia Layer, version SDL 3.4.18, dated... whenever this one dropped πŸŽ€ stay hydrated, stay aligned, and may all your bytes be exactly the value you asked for πŸ¦‹πŸ’–

πŸ“¦ where this page comes from