On Fri, 2009-02-20 at 19:36 -0500, Damian Krzeminski wrote:
> Scott Lawrence wrote:
> > On Tue, 2009-02-17 at 15:55 -0500, Dale Worley wrote:
> >> I'm working on SipRefreshManager, which maintains a UtlHashBag of
> >> RefreshDialogState objects.  SipRefreshManager sets timers, and the
> >> timers' userData fields are pointers to the RefreshDialogState object
> >> that the timer concerns.  The problem is:  When a timer fires, how do I
> >> check that the RefreshDialogState object that the timer points to has
> >> not been removed from the UtlHashBag and deleted?
> > 
> > I would put a reference count in the RefreshDialogState object and use
> > that to ensure that it cannot be deleted until there are no references
> > to it.  Increment the reference when a timer starts or when it is added
> > to the container, and decrement when the timer fires or the object is
> > removed from the container.
> > 
> > That way, your stored pointer is always good.
> > 
> > 
> 
> auto_ptr
> 
> I am just envious: it was not part of the standard during my C++ days...

I don't think that auto_ptr does the whole job.  It just ensures that an
object pointed to by a locally scoped pointer is freed when the pointer
goes out of scope - handy for dealing with dynamic memory leaks in
complex code, but actually not what you want when you're going to store
the pointer.


_______________________________________________
sipx-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev

Reply via email to