[sheepdog] Question about memory allocation functions in lib/util.c
h.mitake at gmail.com
Mon Oct 1 15:46:34 CEST 2012
I have a question about the memory allocation functions in lib/util.c
It seems that xmalloc(), xcalloc(), and xrealloc() try to allocate 1
byte area if first allocation fails
and the size of requested area is 0.
e.g. this is the head part of of xmalloc()
void *xmalloc(size_t size)
void *ret = malloc(size);
if (!ret && !size)
ret = malloc(1);
I couldn't understand the intention of this implementation.
What is the intention of these behaviours?
More information about the sheepdog