SDL_murmur3_32(3)

πŸ’– SDL_murmur3_32 πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, page SDL_murmur3_32(3), and yes we are about to have a whole moment about hashing πŸ¦‹


✨ NAME ✨

SDL_murmur3_32</puruple> β€” calculate a 32-bit MurmurHash3 value for a block of data. that's it, that's the girl πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_stdinc.h>

Uint32 SDL_murmur3_32(const void *data, size_t len, Uint32 seed);

like, look at her. three little params and a dream 🌸


✨ DESCRIPTION ✨

okay so first of all, if you wanna know what MurmurHash even is, the girls are linking the wikipedia page right here in the docs, iconic behaviour:

https://en.wikipedia.org/wiki/MurmurHash

you can specify a seed, and yes, it changes the final results consistently β€” same data plus same seed always gives you the same hash, no cap ✨

but listen to me very carefully bestie 🚨 this does not work like SDL_crc16 and SDL_crc32. with those you can feed a previous result from the function back into itself as the next seed value and calculate a hash in chunks. with this one? nope. it will not produce the same hash as it would if the same data was provided in a single call. so don't try to be cute and stream it in pieces, because the math will simply not cooperate and you'll be sitting there like 😭

and if you're standing there like "what do i even put for a seed??" β€” zero is fine. zero is the vibe. zero ate. 🫢

also important: Murmur3 is not cryptographically secure, so please do not use it for hashing top-secret data. that's not the assignment. put the state secrets down πŸ’€

✨ FUNCTION PARAMETERS ✨

  • data β€” the data to be hashed. the stuff. the material. the moment πŸŽ€
  • len β€” the size of data, in bytes. count 'em, bestie πŸ”’
  • seed β€” a value that alters the final hash value. she's the little seasoning on top ✨

✨ RETURN VALUE ✨

returns a Murmur3 32-bit hash value. one Uint32, freshly calculated, just for you πŸ‘‘


✨ THREAD SAFETY ✨

it is safe to call this function from any thread. so go off, spawn all the threads you want, she's not gonna be weird about it 🌈


✨ AVAILABILITY ✨

this function is available since SDL 3.2.0. so if you're on something older, no she's not there yet πŸ™ˆ


that's the whole page, you understood it, i'm so proud of you, go hash something πŸ¦‹πŸ’–

Simple Directmedia Layer wrote this one, SDL 3.4.18 is the version on the tin, and it's filed under SDL_murmur3_32(3) β€” mwah, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from