]> Savannah Git Hosting - gnulib.git/commitdiff
malloca: Add a compile-time verification.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 2 Feb 2018 23:47:15 +0000 (00:47 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 2 Feb 2018 23:47:15 +0000 (00:47 +0100)
* lib/malloca.c (small_t): Verify that it is wide enough.
* modules/malloca (Depends-on): Add verify.

ChangeLog
lib/malloca.c
modules/malloca

index 85c13f87149fb661082d3f0bb8c0998f114e278d..43731aee28372859ce38d002d12571a98856a791 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-02  Paul Eggert  <eggert@cs.ucla.edu>
+
+       malloca: Add a compile-time verification.
+       * lib/malloca.c (small_t): Verify that it is wide enough.
+       * modules/malloca (Depends-on): Add verify.
+
 2018-02-02  Bruno Haible  <bruno@clisp.org>
 
        malloca: Add an argument check.
index c5321d17e96b6b9d9555860703ce078406de0246..c66e0c88e66413552b51786f04bd116e01d96a1c 100644 (file)
@@ -21,6 +21,8 @@
 /* Specification.  */
 #include "malloca.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
    mmalloca() and freea() in the other case are not critical, because they
@@ -34,6 +36,8 @@
 
 /* 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);
 
 void *
 mmalloca (size_t n)
index 8f5ab644a7eaadea4692cbf110c537487afdc9d0..0ae3fe08dc34138c31ce1a2b4244116d93955366 100644 (file)
@@ -11,6 +11,7 @@ m4/longlong.m4
 Depends-on:
 alloca-opt
 stdint
+verify
 xalloc-oversized
 
 configure.ac: