Boost logo

Boost Users :

Subject: Re: [Boost-users] [smart_ptr]intrusive_ptr suggestion
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-08-11 16:25:50


gast128 wrote:
> We use boost a lot and also the intrusive_ptr to wrap ref counted objects.
> However the intuitive behavior gives memory leaks. For example use a ref
> counted object KFoo:
> intrusive_ptr<IFoo> ptr(new KFoo); // mleak, KFoo is extra ref counted
> ptr.reset(new KFoo) //mleak
> ptr = intrusive_ptr<IFoo>(new KFoo, false); //ok, but Spartan way of writing

Perhaps you should initialize the reference count to zero in the
constructor of IFoo, instead of initializing it to 1.

In Christ,
Steven Watanabe

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at