summaryrefslogtreecommitdiff
path: root/tests/xmalloc.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2022-10-24 22:26:08 +0200
committerJörg Frings-Fürst <debian@jff.email>2022-10-24 22:26:08 +0200
commite97e0882ffc87a91e7818137196f1b74134566df (patch)
tree285662381eaa0514f988142bff0c8a9685c84dc0 /tests/xmalloc.c
parentcc0876a2fa9e703b1064992ab535f3eed57e9c71 (diff)
parentcb4186bef1b44691db4221406d001a8d40c65b4b (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'tests/xmalloc.c')
-rw-r--r--tests/xmalloc.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/xmalloc.c b/tests/xmalloc.c
index 7df74df..84cdf1f 100644
--- a/tests/xmalloc.c
+++ b/tests/xmalloc.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -22,10 +22,11 @@
#include "xalloc.h"
#include "ialloc.h"
-#include "intprops.h"
#include "minmax.h"
+#include <stdckdint.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
static void * _GL_ATTRIBUTE_PURE
@@ -195,7 +196,7 @@ x2nrealloc (void *p, size_t *pn, size_t s)
else
{
/* Set N = floor (1.5 * N) + 1 to make progress even if N == 0. */
- if (INT_ADD_WRAPV (n, (n >> 1) + 1, &n))
+ if (ckd_add (&n, n, (n >> 1) + 1))
xalloc_die ();
}
@@ -236,7 +237,7 @@ xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s)
N_MAX, and what the C language can represent safely. */
idx_t n;
- if (INT_ADD_WRAPV (n0, n0 >> 1, &n))
+ if (ckd_add (&n, n0, n0 >> 1))
n = IDX_MAX;
if (0 <= n_max && n_max < n)
n = n_max;
@@ -251,7 +252,7 @@ xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s)
size_t nbytes;
#endif
idx_t adjusted_nbytes
- = (INT_MULTIPLY_WRAPV (n, s, &nbytes)
+ = (ckd_mul (&nbytes, n, s)
? MIN (IDX_MAX, SIZE_MAX)
: nbytes < DEFAULT_MXFAST ? DEFAULT_MXFAST : 0);
if (adjusted_nbytes)
@@ -263,9 +264,9 @@ xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s)
if (! pa)
*pn = 0;
if (n - n0 < n_incr_min
- && (INT_ADD_WRAPV (n0, n_incr_min, &n)
+ && (ckd_add (&n, n0, n_incr_min)
|| (0 <= n_max && n_max < n)
- || INT_MULTIPLY_WRAPV (n, s, &nbytes)))
+ || ckd_mul (&nbytes, n, s)))
xalloc_die ();
pa = xrealloc (pa, nbytes);
*pn = n;