summaryrefslogtreecommitdiff
path: root/lib/malloca.h
diff options
context:
space:
mode:
authorDaniel Llorens <lloda@sarc.name>2021-08-16 13:23:27 +0200
committerDaniel Llorens <lloda@sarc.name>2021-08-16 13:23:27 +0200
commitb4a80f4239b19fea4d2cc3e9d197f24b809f0624 (patch)
treeb4dc728ec96391e302df4f7c733bf592a3976ff2 /lib/malloca.h
parent5df5555d12f1408a66a5368a918abb981edf5445 (diff)
downloadguile-b4a80f4239b19fea4d2cc3e9d197f24b809f0624.tar.gz
Update gnulib to 8f4538a53d64054ae2fc8b86c0f87c418c6176e6
Includes gnulib:0c907f7da13232908f05c415b8cec56024071906 to fix #49930 https://lists.gnu.org/archive/html/bug-guile/2021-08/msg00003.html.
Diffstat (limited to 'lib/malloca.h')
-rw-r--r--lib/malloca.h36
1 files changed, 19 insertions, 17 deletions
diff --git a/lib/malloca.h b/lib/malloca.h
index 9cf7fbb52..7eb63d2a7 100644
--- a/lib/malloca.h
+++ b/lib/malloca.h
@@ -2,18 +2,18 @@
Copyright (C) 2003-2007, 2009-2021 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _MALLOCA_H
#define _MALLOCA_H
@@ -51,6 +51,13 @@ extern "C" {
# define safe_alloca(N) ((void) (N), NULL)
#endif
+/* Free a block of memory allocated through malloca(). */
+#if HAVE_ALLOCA
+extern void freea (void *p);
+#else
+# define freea free
+#endif
+
/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of
memory allocated on the stack, that must be freed using freea() before
the function returns. Upon failure, it returns NULL. */
@@ -65,21 +72,16 @@ extern "C" {
# define malloca(N) \
mmalloca (N)
#endif
-extern void * mmalloca (size_t n);
-
-/* Free a block of memory allocated through malloca(). */
-#if HAVE_ALLOCA
-extern void freea (void *p);
-#else
-# define freea free
-#endif
+extern void *mmalloca (size_t n)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (freea, 1)
+ _GL_ATTRIBUTE_ALLOC_SIZE ((1));
/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S).
It allocates an array of N objects, each with S bytes of memory,
- on the stack. S must be positive and N must be nonnegative.
- Either N or S should be of type ptrdiff_t or size_t or wider.
+ on the stack. N and S should be nonnegative and free of side effects.
The array must be freed using freea() before the function returns. */
-#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s)))
+#define nmalloca(n, s) \
+ (xalloc_oversized (n, s) ? NULL : malloca ((n) * (size_t) (s)))
#ifdef __cplusplus