|
Boost Users : |
Subject: Re: [Boost-users] [smart_ptr]intrusive_ptr suggestion
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-08-11 16:25:50
AMDG
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 hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net