Pádraig Brady wrote: > I wrote a quick test program on glibc-2.7 to show: > malloc (0)==valid_ptr > realloc (valid_ptr,0)==NULL > realloc (NULL,0)==valid_ptr > The interesting case there is the middle one which is not > covered by the AC_FUNC_REALLOC check as far as I can see.
I confirm your findings. This means that the 'realloc' module does not help when coding like this: size_t n = 10; void *p = malloc (n); ... for (;;) { ... n = ...; /* larger than the original n */ p = realloc (p, n); } Neither does it help in code like this: size_t n = 0; void *p = NULL; ... for (;;) { ... n = ...; /* larger than the original n */ p = realloc (p, n); } Neither does it help in code like this: size_t n = 0; void *p = NULL; ... if (...) { n = /* some value */; p = realloc (p, n); ... } if (...) { n = /* some value */; p = realloc (p, n); ... } It's hard to imagine a code in which the 'realloc' module is useful. I therefore propose to deprecate this module. Nothing in gnulib, gettext, nor coreutils uses the module. (coreutils/bootstrap.conf mentions the module, but it does not really need it. I checked all realloc() calls in coreutils.) Bruno