From 26112352a774737e1ce5580c93654a26c1e82b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 24 Oct 2022 22:25:29 +0200 Subject: New upstream version 1.1 --- lib/malloca.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/malloca.c') 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 + #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; -- cgit v1.2.3