Date: Thu, 20 Aug 1998 21:08:59 -0600 From: Warner Losh <imp@village.org> To: Brian Somers <brian@Awfulhak.org> Cc: Archie Cobbs <archie@whistle.com>, nate@mt.sri.com (Nate Williams), hackers@FreeBSD.ORG Subject: Re: Realloc fix for review Message-ID: <199808210309.VAA26640@harmony.village.org> In-Reply-To: Your message of "Fri, 21 Aug 1998 02:07:35 BST." <199808210107.CAA13727@awfulhak.org> References: <199808210107.CAA13727@awfulhak.org>
index | next in thread | previous in thread | raw e-mail
In message <199808210107.CAA13727@awfulhak.org> Brian Somers writes:
: AFAIK not all free() implementations ignore a NULL pointer (although
: FreeBSD's does). But then, not all realloc() implementations allow a
: NULL either (FreeBSD's does) :-/
free(NULL); is required to be valid by tha ANSI standard. I don't
know about the realloc(NULL, s); case, however.
But, the frealloc, as I implemented it (rather than how I posted it)
looks exactly like:
#include <stdlib.h>
void *
frealloc(void *ptr, size_t size)
{
void *nptr;
nptr = realloc(ptr, size);
if (!nptr && ptr)
free(ptr);
return (nptr);
}
which does try to avoid calling free(NULL).
Warner
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808210309.VAA26640>
