Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Aug 1998 14:03:08 -0600
From:      Warner Losh <imp@village.org>
To:        Nate Williams <nate@mt.sri.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Realloc fix for review 
Message-ID:  <199808202003.OAA23791@harmony.village.org>
In-Reply-To: Your message of "Thu, 20 Aug 1998 13:49:38 MDT." <199808201949.NAA08010@mt.sri.com> 
References:  <199808201949.NAA08010@mt.sri.com>  <199808201619.KAA20970@harmony.village.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <199808201949.NAA08010@mt.sri.com> Nate Williams writes:
: In short, I think it's the *wrong* thing to do, and has too many worse
: side-effects than the original code.

No nate.  You've read my patch wrong.

If the realloc fails, it reutnrs NULL.  When it returns NULL, the
right thing to do is to free the old pointer.  However, only in cases
where the old code was
	a = realloc(a, src)
but not when the old code was
	b = realloc(a,src)
since the first destroys A in the failure case.  At that point, the
memory is leaked.

Warner

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808202003.OAA23791>