[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory leak & patch

From: Larry Jones
Subject: Re: memory leak & patch
Date: Wed, 11 Jun 2003 14:47:06 -0400 (EDT)

Kenneth Lorber writes:
> I think the addition of the final free() fixes a real leak.  (owd comes from
> xgetwd(), and xgetwd()'s return value needs to be free()'d.)

Ahh, right you are!  I missed the wheat amongst the chaff.  I've checked
in your fix.  Thanks!

> The free()'s before the calls to error() bring up a style issue.  If I'm
> debugging a program, I want it to release all memory before it exit()'s so
> I can see what's leaked, even if I'm exiting on an error.  If cvs
> doesn't get coded that way, my apologies for not noticing and cleaning up
> too much :-)

While that's a noble goal, it's essentially unachievable in a language
like C -- error exits would have to return normally all the way up the
call stack to give each routine a chance to clean up.  The "correct"
definition of leaked memory is not memory that's still allocated at exit
but rather memory that is no longer accessible because you no longer
have a pointer to it.  CVS tries very hard to avoid memory leaks in that
sense; it makes no attempt whatsoever to avoid memory leaks in your

-Larry Jones

If I was being raised in a better environment, I wouldn't
do things like that. -- Calvin

reply via email to

[Prev in Thread] Current Thread [Next in Thread]