[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_FUNC_MALLOC
From: |
Paul Eggert |
Subject: |
Re: AC_FUNC_MALLOC |
Date: |
Tue, 29 Oct 2002 12:31:23 -0800 (PST) |
> From: Akim Demaille <address@hidden>
> Date: 29 Oct 2002 14:50:29 +0100
>
> AFAIC, this macro is fine in Autoconf. But I'm waiting for other
> opinions.
I think the macro is OK, since it encourages a programming style that
is easier to read and maintain, and which works just fine with glibc.
However, the documentation was misleading, so I installed this patch.
Note that I also changed "char *" to "void *". "char *" does not
conform to the C standard. I think the "char *" was there for
compatibility with some buggy pre-K&R C compilers, but I don't think
we need to worry about them any more, at least not in example code.
Index: autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.705
retrieving revision 1.706
diff -p -u -r1.705 -r1.706
--- autoconf.texi 29 Oct 2002 13:07:19 -0000 1.705
+++ autoconf.texi 29 Oct 2002 20:22:54 -0000 1.706
@@ -3776,7 +3776,8 @@ If @code{lstat} behaves properly, define
@cvindex malloc
@c @fuindex malloc
@prindex @code{malloc}
-If the @code{malloc} function works correctly (@samp{malloc (0)} returns a
valid
+If the @code{malloc} function is compatible with the @acronym{GNU} C
+library @code{malloc} (i.e., @samp{malloc (0)} returns a valid
pointer), define @code{HAVE_MALLOC} to 1. Otherwise define
@code{HAVE_MALLOC} to 0, ask for an @code{AC_LIBOBJ} replacement for
@samp{malloc}, and define @code{malloc} to @code{rpl_malloc} so that the
@@ -3793,12 +3794,12 @@ the @samp{#undef malloc}):
#include <sys/types.h>
-char *malloc ();
+void *malloc ();
/* Allocate an N-byte block of memory from the heap.
If N is zero, allocate a 1-byte block. */
-char *
+void *
rpl_malloc (size_t n)
{
if (n == 0)
@@ -3862,7 +3863,8 @@ If the obstacks are found, define @code{
@cvindex realloc
@c @fuindex realloc
@prindex @code{realloc}
-If the @code{realloc} function works correctly (@samp{realloc (0, 0)} returns a
+If the @code{realloc} function is compatible with the @acronym{GNU} C
+library @code{realloc} (i.e., @samp{realloc (0, 0)} returns a
valid pointer), define @code{HAVE_REALLOC} to 1. Otherwise define
@code{HAVE_REALLOC} to 0, ask for an @code{AC_LIBOBJ} replacement for
@samp{realloc}, and define @code{realloc} to @code{rpl_realloc} so that
@@ -4584,7 +4586,7 @@ with the system's one, you should use:
@example
#if defined HAVE_DECL_MALLOC && !HAVE_DECL_MALLOC
-char *malloc (size_t *s);
+void *malloc (size_t *s);
#endif
@end example
@@ -5751,7 +5753,7 @@ include any header files containing clas
#ifdef __cplusplus
extern "C" void *malloc (size_t);
#else
-char *malloc ();
+void *malloc ();
#endif
@end example
- AC_FUNC_MALLOC, Bruno Haible, 2002/10/29
- Re: AC_FUNC_MALLOC, Akim Demaille, 2002/10/29
- Re: AC_FUNC_MALLOC, Bruno Haible, 2002/10/29
- Re: AC_FUNC_MALLOC, Akim Demaille, 2002/10/29
- Re: AC_FUNC_MALLOC,
Paul Eggert <=
- Re: AC_FUNC_MALLOC, Bruno Haible, 2002/10/31
- Re: AC_FUNC_MALLOC, Akim Demaille, 2002/10/31
- Re: AC_FUNC_MALLOC, Bruno Haible, 2002/10/31
- Re: AC_FUNC_MALLOC, Akim Demaille, 2002/10/31