MCPcopy Create free account
hub / github.com/containers/bubblewrap / xadd

Function xadd

utils.c:966–980  ·  view source on GitHub ↗

* Return a + b if it would not overflow. * Die with an "out of memory" error if it would. */

Source from the content-addressed store, hash-verified

964 * Die with an "out of memory" error if it would.
965 */
966static size_t
967xadd (size_t a, size_t b)
968{
969#if defined(__GNUC__) && __GNUC__ >= 5
970 size_t result;
971 if (__builtin_add_overflow (a, b, &result))
972 die_oom ();
973 return result;
974#else
975 if (a > SIZE_MAX - b)
976 die_oom ();
977
978 return a + b;
979#endif
980}
981
982/*
983 * Return a * b if it would not overflow.

Callers 2

strappendFunction · 0.85
strappendfFunction · 0.85

Calls 1

die_oomFunction · 0.85

Tested by

no test coverage detected