SDL_memcmp(3)
π SDL_memcmp(3) β the vibe check for your memory buffers π
okay so bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where today we're doing SDL_memcmp β literally the function that looks at two chunks of memory and is like "hmm, who's bigger tho" β¨
πΈ NAME πΈ
SDL_memcmp β compare two buffers of memory. that's it, that's the whole job, and she does it flawlessly π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_stdinc.h>
int SDL_memcmp(const void *s1, const void *s2, size_t len);
look at her. short. iconic. no notes. π«Ά
π FUNCTION PARAMETERS π
s1β the first buffer to compare. and listen, NULL is not permitted! like, do NOT pass NULL, she will not be chill about it π«πs2β the second buffer to compare. same energy, NULL is not permitted! fr fr, do not do it πlenβ the number of bytes to compare between the buffers. so like, how far down the line are we checking? you decide, bestie π¦
π RETURN VALUE π
she gives you a whole int and honestly the number is telling you a story:
- less than zero β
s1is "less than"s2π - greater than zero β
s1is "greater than"s2π₯ - zero β the buffers match exactly for
lenbytes π₯³ slay
so yeah, zero is the good one. zero means they're twins. π―
π§ THREAD SAFETY π§
good news babes β it is safe to call this function from any thread. no drama, no locking, no gatekeeping. every thread can pull up π
β AVAILABILITY β
this one's been around since SDL 3.2.0. so if you're on something olderβ¦ girl, upgrade π
lowkey reminder: this is the memory-comparing sister of the whole string-compare family, so if you know her, you know her. iykyk π
and that's the tea, bestie! this page came to you from Simple Directmedia Layer, living in SDL 3.4.18, filed under SDL_memcmp(3) in the SDL3 FUNCTIONS collection. mwah, go compare some buffers responsibly ππ
β¨
π¦ 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