lilypond-devel
[Top][All Lists]
Advanced

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

Re: Fix memleak: temporary skyline objects for systems were never delete


From: Han-Wen Nienhuys
Subject: Re: Fix memleak: temporary skyline objects for systems were never deleted (issue 4923048)
Date: Wed, 24 Aug 2011 17:24:45 -0300

On Wed, Aug 24, 2011 at 10:57 AM, David Kastrup <address@hidden> wrote:
> Han-Wen Nienhuys <address@hidden> writes:
>
>>> Skylines are smobs.  The usual way to delete them would be to
>>> unprotect them once they have been registered by some
>>> garbage-collectable object (or a SCM variable that is being used for
>>> accessing them).
>>
>> They are simple smobs, though, so this pattern here is not uncommon.
>> You could also try to allocate them on the stack.
>
> I think it would make me less uncomfortable than using explicit delete.

I don't think in the end neither choice matters very much; the stack
is also awkward, because the instantiation happens in a if(){}.  I
would probably write as follows

  Skyline *withpadding = 0;
  ...
  if ( .. )  {
     withpadding = new Skyline( .. )
  }

  delete withpadding;

this still has a leak-risk if someone adds a return in the middle. To
fix that, you'd have to use  something like Boost's scoped_ptr<>.

-- 
Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwen



reply via email to

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