Paul Eggert wrote:
> diff --git a/lib/malloca.h b/lib/malloca.h
> index 6fa1d8b20..dbbec3f06 100644
> --- a/lib/malloca.h
> +++ b/lib/malloca.h
> @@ -65,7 +65,6 @@ 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
> @@ -74,6 +73,10 @@ extern void freea (void *p);
> # 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. N and S should be nonnegative and free of side effects.
malloca and mmalloca belong close together. I prefer to move the 'freea'
declaration, so that malloca and mmalloca are declared together.
2021-08-07 Bruno Haible <[email protected]>
malloca: Tweak last commit.
* lib/malloca.h: Keep use and declaration of mmalloca close together.
diff --git a/lib/malloca.h b/lib/malloca.h
index dbbec3f..7eb63d2 100644
--- a/lib/malloca.h
+++ b/lib/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,14 +72,6 @@ extern "C" {
# define malloca(N) \
mmalloca (N)
#endif
-
-/* 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));