summaryrefslogtreecommitdiff
path: root/lib/malloca.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2022-12-08 17:35:13 +0100
committerJörg Frings-Fürst <debian@jff.email>2022-12-08 17:35:13 +0100
commit1b1ad4ed2919fbc68d8905cfec38a968821ce372 (patch)
tree5532a7e21342f88f4df7cd42139e012b6bd1dbe6 /lib/malloca.c
parent63b5c0db2dc641876e58d232220c7efc2b2c2423 (diff)
parentfa82e850f8d894ae4b9cd75bd12ffeeb65974d50 (diff)
Merge branch 'release/debian/1.1-1_experimental1'debian/1.1-1_experimental1
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 e7beaaf0..1e19978d 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;