[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Query on kdelibs/kdecore/io/kgrantpty.c
From:       Oswald Buddenhagen <ossi () kde ! org>
Date:       2007-07-29 12:48:07
Message-ID: 20070729124807.GA6839 () ugly ! local
[Download RAW message or body]

On Sun, Jul 29, 2007 at 02:38:26AM -0500, Boyd Stephen Smith Jr. wrote:
> On Sunday 29 July 2007 02:15:54 am Brad Hards wrote:
> > One that does look like an error is in kgrantpty.c
> > Around line 149 is this line:
> >     tty = malloc(strlen(pty) + 1);
> >
> > That never gets free()'d that I can see.
> >
> > Does that count as a bug, or is it OK because this is a standalone
> > application and it gets cleaned up on exit?
> 
> It's a bug, in that application.  A non-buggy OS will clean up where
> the application doesn't though, so if the application isn't meant to
> be long-running it shouldn't cause many problems.  (It's still a bug
> though.)
> 
nonsense. relying on the os doing cleanup is *perfectly* ok. small
chunks aren't returned to the os anyway until the program terminates.
so as long as no allocations are done after unallocations could have
been done and thus the peak memory usage does not increase, one can
completely forget about freeing.
and when the total footprint is in the range of a few bytes and the
runtime is in the milliseconds one can forget about freeing no matter
what the allocation pattern looks like.

so an intelligent analyzer will only complain if allocations are done
after references to allocated memory have been lost (or it is known that
the still held pointers won't be used any more). additionally, it should
shut up below certain thresholds alltogether. have fun with implementing
*that*. ;)

> I'd imagine that code could be fairly easily replaced with some QString or 
> QByteArray code.
> 
right. i'll instantly turn it into a .cpp file, link to QtCore and its
~10 dependencies, at least tripling the startup time and increasing the
build time tenfold.
oh, right, kgrantpty was just an example ...

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic