summaryrefslogtreecommitdiffstats
path: root/configure.in
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-07-10 22:42:38 (GMT)
committerGuido van Rossum <guido@python.org>1997-07-10 22:42:38 (GMT)
commitad7137027916b3c2ec409eeb0eaf99af921dccf4 (patch)
tree6068ed5e79a31939d8b3586a4915839da8b96cbe /configure.in
parent4b11c74f7c26038f94565a5b73d102bd96cc0e9f (diff)
downloadcpython-ad7137027916b3c2ec409eeb0eaf99af921dccf4.zip
cpython-ad7137027916b3c2ec409eeb0eaf99af921dccf4.tar.gz
cpython-ad7137027916b3c2ec409eeb0eaf99af921dccf4.tar.bz2
Added check whether malloc(0) returns NULL or not.
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in26
1 files changed, 26 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 1f9ba21..f2510ce 100644
--- a/configure.in
+++ b/configure.in
@@ -582,6 +582,32 @@ AC_MSG_RESULT($ac_cv_func_getopt)
test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
AC_SUBST(LIBOBJS)dnl
+# check whether malloc(0) returns NULL or not
+AC_SUBST(MALLOC_ZERO_RETURNS_NULL)
+AC_MSG_CHECKING(what malloc(0) returns)
+AC_CACHE_VAL(ac_cv_malloc_zero,
+[AC_TRY_RUN([#include <stdio.h>
+#ifdef HAVE_STDLIB
+#include <stdlib.h>
+#else
+char *malloc(), *realloc();
+int *free();
+#endif
+main() {
+ char *p;
+ p = malloc(0);
+ if (p == NULL) exit(1);
+ p = realloc(p, 0);
+ if (p == NULL) exit(1);
+ free(p);
+ exit(0);
+}], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
+AC_MSG_RESULT($ac_cv_malloc_zero)
+if test "$ac_cv_malloc_zero" = null
+then
+ AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
+fi
+
# generate output files
AC_OUTPUT(Makefile \
Objects/Makefile \