Hi, C89, SUSv3[1] and glibc for Linux do free(p) when realloc(p,0) is called and p != 0. The patch fixes this incompatibility in `libc/hurd/hurdmalloc.c'.
Again, this patched is not tested and it must be applied after the previous patch about `malloc((1<<31)-1)'. Regards [1] http://www.opengroup.org/onlinepubs/007904975/functions/realloc.html -- Ognyan Kulev <[EMAIL PROTECTED]>, "\"Programmer\""
2002-03-25 Ognyan Kulev <[EMAIL PROTECTED]> * hurdmalloc.c (realloc): realloc(p,0) calls free(p) and returns 0 when p != 0.
--- hurdmalloc.c.patched-malloc Mon Mar 25 19:16:56 2002 +++ hurdmalloc.c Mon Mar 25 19:47:19 2002 @@ -388,6 +388,12 @@ realloc(old_base, new_size) if (old_base == 0) return malloc (new_size); + if (new_size == 0) + { + free (old_base); + return 0; + } + /* * Find size of old block. */ @@ -428,7 +434,7 @@ realloc(old_base, new_size) memcpy (new_base, old_base, (int) (old_size < new_size ? old_size : new_size)); - if (new_base || new_size == 0) + if (new_base) /* Free OLD_BASE, but only if the malloc didn't fail. */ free (old_base);