GLib – 2.0: Bounds-checking Integer Arithmetic
Description: Reference for GLib-2.0: Bounds-checking Integer Arithmetic

#### Bounds-checking Integer Arithmetic

GLib offers a set of macros for doing additions and multiplications of unsigned integers, with checks for overflows.

The helpers all have three arguments. A pointer to the destination is always the first argument and the operands to the operation are the other two.

Following standard GLib convention, the helpers return true in case of success (ie: no overflow).

The helpers may be macros, normal functions or inlines. They may be implemented with inline assembly or compiler intrinsics where available.

Since: 2.48

The APIs are:

- `g_uint_checked_add()`
- `g_uint_checked_mul()`
- `g_uint64_checked_add()`
- `g_uint64_checked_mul()`
- `g_size_checked_add()`
- `g_size_checked_mul()`