gnash-commit
[Top][All Lists]
Advanced

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

Re: [Gnash-commit] /srv/bzr/gnash/trunk r9668: Plug leak.


From: Benjamin Wolsey
Subject: Re: [Gnash-commit] /srv/bzr/gnash/trunk r9668: Plug leak.
Date: Thu, 04 Sep 2008 09:08:11 +0200

> > + std::for_each(_audioQueue.begin(), _audioQueue.end(), &cleanQueue);
> 
> In a slightly more generalised fashion, you could also write:
> 
>    std::for_each(_audioQueue.begin(), _audioQueue.end(), 
> boost::checked_deleter<media::raw_mediadata_t>());

Yes, but I think using the container's value_type to generalize the
deleting function makes maintenance easier, and because it's a pointer
that won't work with the checked deleter. For anyone who's not familiar
with it, the boost deleter makes sure that the type is complete at the
time of deletion, which is very sensible, though in this particular case
not a danger.

A generalized deleting template for containers with pointers might look
like:

template<typename T>
void pointerDeleter(typename T::value_type p)
{
        delete p
}

´╗┐std::for_each(_audioQueue.begin(), _audioQueue.end(),
&pointerDeleter<AudioQueue>);

This has some compile time checks (namely that the container contains
pointers and that the deleted type matches the iterators), but lacks
boost's completeness check, of course.

It would be slightly less work then to change the type held in the
AudioQueue.

bwy

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


reply via email to

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