On Wed, Aug 24, 2011 at 10:57 AM, David Kastrup <d...@gnu.org> wrote:
> Han-Wen Nienhuys <hanw...@gmail.com> 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 - han...@xs4all.nl - http://www.xs4all.nl/~hanwen

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to