Date: Fri, 21 Aug 1998 01:59:23 +0100 From: Brian Somers <brian@Awfulhak.org> To: Warner Losh <imp@village.org> Cc: "Jordan K. Hubbard" <jkh@time.cdrom.com>, dag-erli@ifi.uio.no (Dag-Erling Coidan =?iso-8859-1?Q?Sm=F8rgrav?= ), hackers@FreeBSD.ORG Subject: Re: Realloc fix for review Message-ID: <199808210059.BAA13468@awfulhak.org> In-Reply-To: Your message of "Thu, 20 Aug 1998 13:09:38 MDT." <199808201909.NAA21884@harmony.village.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[.....] > No, this only replaces those places where the old pointer was > destroyed rather than a s/realloc/frealloc/g. I was careful to only > change those places where I knew that matched the pattern > a = realloc(a,size); > and didn't change those where they had: > b = realloc(a,size); > Since in the former case you've lost any reference to the old memory, > the right thing to do is to free it up. Since I couldn't change > realloc to have those semantics, I created frealloc which is easier to > use than realloc() in the cases where you want the old memory freed > when it can't allocate new memory. It's still wrong: char *a, *b, *c; ..... a = b; b = realloc(b, 10); if (b == NULL) b = a; ..... or b = NULL; ..... b = realloc(b, 10); etc. Blind replacements are a bad idea. > Warner -- Brian <brian@Awfulhak.org>, <brian@FreeBSD.org>, <brian@OpenBSD.org> <http://www.Awfulhak.org> Don't _EVER_ lose your sense of humour.... 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?199808210059.BAA13468>