MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__addsizes_valid

Function stbi__addsizes_valid

include/stb/stb_image.h:1002–1010  ·  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

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