summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-malloc.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2018-02-25 10:20:31 +1100
committerDarren Tucker <dtucker@dtucker.net>2018-02-26 00:09:04 +1100
commite9dede06e5bc582a4aeb5b1cd5a7a640d7de3609 (patch)
treef149ff2fb7ff3d427cfd1e7fcee416e7922ada84 /openbsd-compat/bsd-malloc.c
parent2eb4041493fd2635ffdc64a852d02b38c4955e0b (diff)
Handle calloc(0,x) where different from malloc.
Configure assumes that if malloc(0) returns null then calloc(0,n) also does. On some old platforms (SunOS4) malloc behaves as expected (as determined by AC_FUNC_MALLOC) but calloc doesn't. Test for this at configure time and activate the replacement function if found, plus handle this case in rpl_calloc.
Diffstat (limited to 'openbsd-compat/bsd-malloc.c')
-rw-r--r--openbsd-compat/bsd-malloc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/openbsd-compat/bsd-malloc.c b/openbsd-compat/bsd-malloc.c
index 6402ab588..482facdc9 100644
--- a/openbsd-compat/bsd-malloc.c
+++ b/openbsd-compat/bsd-malloc.c
@@ -50,6 +50,8 @@ rpl_realloc(void *ptr, size_t size)
50{ 50{
51 if (size == 0) 51 if (size == 0)
52 size = 1; 52 size = 1;
53 if (ptr == 0)
54 return malloc(size);
53 return realloc(ptr, size); 55 return realloc(ptr, size);
54} 56}
55#endif 57#endif