File: checked-math.md

package info (click to toggle)
glib2.0 2.84.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 66,112 kB
  • sloc: ansic: 538,924; python: 9,661; sh: 1,612; xml: 1,482; perl: 1,222; cpp: 535; makefile: 321; javascript: 11
file content (30 lines) | stat: -rw-r--r-- 903 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Title: Bounds-checking Integer Arithmetic
SPDX-License-Identifier: LGPL-2.1-or-later
SPDX-FileCopyrightText: 2015 Allison Lortie

# 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:

 * [func@GLib.uint_checked_add]
 * [func@GLib.uint_checked_mul]
 * [func@GLib.uint64_checked_add]
 * [func@GLib.uint64_checked_mul]
 * [func@GLib.size_checked_add]
 * [func@GLib.size_checked_mul]