SDL_size_add_check_overflow(3)
π SDL_size_add_check_overflow(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we do math but like, safely β¨ this one's a lil header-only baddie from SDL_stdinc.h and she is lowkey doing the most important job: catching overflow before it ruins your whole day π«Ά
πΈ NAME πΈ
SDL_size_add_check_overflow</purpose> β add two integers, and check for overflow while you're at it π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_stdinc.h>
SDL_FORCE_INLINE bool SDL_size_add_check_overflow(size_t a, size_t b, size_t *ret);
like yes she's SDL_FORCE_INLINE, she's got zero chill and zero function-call overhead, we stan π
π¦ DESCRIPTION π¦
so here's the tea β: if a + b would overflow, you get false back. that's it, that's the vibe check, no cap π
otherwise, she stores a + b through ret and hits you with true π
it's giving "trust but verify" and honestly? iconic π
π FUNCTION PARAMETERS π
aβ the first addend πbβ the second addend πretβ on non-overflow output, this stores the addition result. it may not beNULLβ fr fr, do not passNULLhere, that's not the move π
β RETURN VALUE β
- returns
falseon overflow π - returns
trueif the result gets added without overflow β¨
π§ THREAD SAFETY π§
it is safe to call this function from any thread. yes bestie, ANY. go wild, she's built different π«Ά
π AVAILABILITY π
this function is available since SDL 3.2.0 β so if you're on anything older, sorry babes, no overflow-checking for you π
and that's the whole page, you ate it π β¨ this lil love letter comes to you from Simple Directmedia Layer, shipping as SDL 3.4.18 β mwah, go forth and never overflow again ππ¦π
π¦ 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