diff options
author | Kevin E Martin <kem@kem.org> | 2005-12-09 15:28:41 +0000 |
---|---|---|
committer | Kevin E Martin <kem@kem.org> | 2005-12-09 15:28:41 +0000 |
commit | af0164c2ded2dcc95b72ca3b9bfbad9b790490f7 (patch) | |
tree | 5e2abbefb097cbb8d5b7797b4ba7de02b342849d /xorg-macros.m4 | |
parent | 80c3aba8ac4af96c3d9407ecbed2f6c813adbbe1 (diff) |
Better macro to check whether any of malloc(0), realloc(ptr,0) or calloc(0)MODULAR_COPY
return NULL since Xlib expects all three to return a valid pointer.
Diffstat (limited to 'xorg-macros.m4')
-rw-r--r-- | xorg-macros.m4 | 9 |
1 files changed, 8 insertions, 1 deletions
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]) |