MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / mul_safe

Function mul_safe

Source/astcenc_mathlib.h:493–501  ·  view source on GitHub ↗

* @brief Compute the product of two sizes. * * This function is implemented to indicate if overflow has occurred, which may * occur when input values are not trusted. Implementation is obviously slower * than one that does not do this, so don't use for values we know cannot * overflow. * * Overflow signaling is sticky, so calling code can check at the end of a * sequence of multiplies. *

Source from the content-addressed store, hash-verified

491 * @return The multiplication result, which may have overflowed.
492 */
493static inline size_t mul_safe(
494 size_t val_a,
495 size_t val_b,
496 bool& overflow
497) {
498 size_t result = val_a * val_b;
499 overflow = overflow || ((val_b != 0) && ((result / val_b) != val_a));
500 return result;
501}
502
503/**
504 * @brief Get the number of blocks along a single axis.

Callers 7

get_texels_countFunction · 0.85
get_blocks_countFunction · 0.85
load_cimageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected