summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--xorg-macros.m49
2 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index afc372c..093db90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-12-09 Kevin E. Martin <kem-at-freedesktop-dot-org>
+
+ * 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 <kem-at-freedesktop-dot-org>
* 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])