summaryrefslogtreecommitdiff
path: root/lib/malloca.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2022-10-24 22:25:44 +0200
committerJörg Frings-Fürst <debian@jff.email>2022-10-24 22:25:44 +0200
commitcb4186bef1b44691db4221406d001a8d40c65b4b (patch)
tree285662381eaa0514f988142bff0c8a9685c84dc0 /lib/malloca.c
parentcc0876a2fa9e703b1064992ab535f3eed57e9c71 (diff)
parent26112352a774737e1ce5580c93654a26c1e82b39 (diff)
Update upstream source from tag 'upstream/1.1'
Update to upstream version '1.1' with Debian dir acc8a9214de592a0bbbdb680385559210b329d52
Diffstat (limited to 'lib/malloca.c')
-rw-r--r--lib/malloca.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/malloca.c b/lib/malloca.c
index e7beaaf..1e19978 100644
--- a/lib/malloca.c
+++ b/lib/malloca.c
@@ -21,9 +21,9 @@
/* Specification. */
#include "malloca.h"
+#include <stdckdint.h>
+
#include "idx.h"
-#include "intprops.h"
-#include "verify.h"
/* The speed critical point in this file is freea() applied to an alloca()
result: it must be fast, to match the speed of alloca(). The speed of
@@ -39,7 +39,7 @@
/* Type for holding very small pointer differences. */
typedef unsigned char small_t;
/* Verify that it is wide enough. */
-verify (2 * sa_alignment_max - 1 <= (small_t) -1);
+static_assert (2 * sa_alignment_max - 1 <= (small_t) -1);
void *
mmalloca (size_t n)
@@ -50,17 +50,16 @@ mmalloca (size_t n)
uintptr_t alignment2_mask = 2 * sa_alignment_max - 1;
int plus = sizeof (small_t) + alignment2_mask;
idx_t nplus;
- if (!INT_ADD_WRAPV (n, plus, &nplus) && !xalloc_oversized (nplus, 1))
+ if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1))
{
char *mem = (char *) malloc (nplus);
if (mem != NULL)
{
uintptr_t umem = (uintptr_t)mem, umemplus;
- /* The INT_ADD_WRAPV avoids signed integer overflow on
+ /* The ckd_add avoids signed integer overflow on
theoretical platforms where UINTPTR_MAX <= INT_MAX. */
- INT_ADD_WRAPV (umem, sizeof (small_t) + sa_alignment_max - 1,
- &umemplus);
+ ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1);
idx_t offset = ((umemplus & ~alignment2_mask)
+ sa_alignment_max - umem);
void *vp = mem + offset;