SDL_size_mul_check_overflow(3)

πŸ’– SDL_size_mul_check_overflow(3) πŸ’–

okay bestie, so this is a page from the SDL3 FUNCTIONS manual and it's literally about one of the most underrated little functions ever β€” multiplying two numbers without letting your math silently explode. slay. πŸŽ€


✨ NAME ✨

SDL_size_mul_check_overflow β€” Multiply two integers, checking for overflow.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

SDL_FORCE_INLINE bool SDL_size_mul_check_overflow(size_t a, size_t b, size_t *ret);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: if a * b would overflow, it returns false. that's it, that's the whole safety net 🫢

otherwise, it stores a * b via ret and returns true. no cap, that's the entire deal.


πŸ’… FUNCTION PARAMETERS πŸ’…

  • a β€” the multiplicand. (that's the first number getting multiplied, iykyk)
  • b β€” the multiplier. (the one doing the multiplying ✨)
  • ret β€” on non-overflow output, stores the multiplication result, and it may not be NULL. like, do not pass NULL here, she will not be okay with that πŸ™ˆ

⭐ RETURN VALUE ⭐

Returns false on overflow, true if result is multiplied without overflow. main character binary energy, truly. πŸ‘‘


🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. yes bestie, any thread, go wild, it's giving totally chill. πŸ’œ


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.2.0. so if you're on anything older… it's not there, sorry babe 😭


and that's the whole page, you're officially a SDL_size_mul_check_overflow expert now πŸ’…βœ¨

this little cutie comes to you from Simple Directmedia Layer, rocking version SDL 3.4.18 β€” mwah, go multiply responsibly, bestie πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from