From af0164c2ded2dcc95b72ca3b9bfbad9b790490f7 Mon Sep 17 00:00:00 2001 From: Kevin E Martin Date: Fri, 9 Dec 2005 15:28:41 +0000 Subject: Better macro to check whether any of malloc(0), realloc(ptr,0) or calloc(0) return NULL since Xlib expects all three to return a valid pointer. --- ChangeLog | 7 +++++++ xorg-macros.m4 | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index afc372c..093db90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-12-09 Kevin E. Martin + + * xorg-macros.m4: + Better macro to check whether any of malloc(0), realloc(ptr,0) or + calloc(0) return NULL since Xlib expects all three to return a + valid pointer. + 2005-12-08 Kevin E. Martin * xorg-macros.m4: diff --git a/xorg-macros.m4 b/xorg-macros.m4 index 0284399..e4b8980 100644 --- a/xorg-macros.m4 +++ b/xorg-macros.m4 @@ -241,8 +241,15 @@ AC_MSG_CHECKING([whether malloc(0) returns NULL]) if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then AC_RUN_IFELSE([ char *malloc(); +char *realloc(); +char *calloc(); main() { - exit(malloc(0) == NULL ? 0 : 1); + char *m0, *r0, *c0, *p; + m0 = malloc(0); + p = malloc(10); + r0 = realloc(p,0); + c0 = calloc(0); + exit(m0 == 0 || r0 == 0 || c0 == 0 ? 0 : 1); }], [MALLOC_ZERO_RETURNS_NULL=yes], [MALLOC_ZERO_RETURNS_NULL=no]) -- cgit v1.2.3