mirror of
https://github.com/haproxy/haproxy.git
synced 2026-05-21 01:15:17 -04:00
Sometimes we'd like to know if some products overflow, so let's add a pair of functions for this, for ulong and for size_t. For recent enough compilers (gcc >= 5, clang >= 3.4) we just use __builtin_mul_overflow() otherwise we rely on a division and a comparison before performing the operation. A third function, array_size_or_fail() computes the size of an array of m elements of n bytes each, and returns the total size if it fits in a size_t, otherwise ~0 if it does not so that passing this to malloc() or any other variant would fail by trying to exhaust the entire memory space. |
||
|---|---|---|
| .. | ||
| haproxy | ||
| import | ||
| make | ||