MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__addsizes_valid

Function stbi__addsizes_valid

lite/example/cpp_example/mge/cv/stb_image.h:1027–1035  ·  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

1025// return 1 if the sum is valid, 0 on overflow.
1026// negative terms are considered invalid.
1027static int stbi__addsizes_valid(int a, int b) {
1028 if (b < 0)
1029 return 0;
1030 // now 0 <= b <= INT_MAX, hence also
1031 // 0 <= INT_MAX - b <= INTMAX.
1032 // And "a + b <= INT_MAX" (which might overflow) is the
1033 // same as a <= INT_MAX - b (no overflow)
1034 return a <= INT_MAX - b;
1035}
1036
1037// returns 1 if the product is valid, 0 on overflow.
1038// 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