MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__addsizes_valid

Function stbi__addsizes_valid

Source/Utils/stb_image.h:1001–1009  ·  view source on GitHub ↗

return 1 if the sum is valid, 0 on overflow. negative terms are considered invalid.

Source from the content-addressed store, hash-verified

999// return 1 if the sum is valid, 0 on overflow.
1000// negative terms are considered invalid.
1001static int stbi__addsizes_valid(int a, int b)
1002{
1003 if (b < 0) return 0;
1004 // now 0 <= b <= INT_MAX, hence also
1005 // 0 <= INT_MAX - b <= INTMAX.
1006 // And "a + b <= INT_MAX" (which might overflow) is the
1007 // same as a <= INT_MAX - b (no overflow)
1008 return a <= INT_MAX - b;
1009}
1010
1011// returns 1 if the product is valid, 0 on overflow.
1012// negative factors are considered invalid.

Callers 3

stbi__mad2sizes_validFunction · 0.85
stbi__mad3sizes_validFunction · 0.85
stbi__mad4sizes_validFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected