List:MySQL++« Previous MessageNext Message »
From:Jonathan Wakely Date:November 30 2007 2:15am
Subject:Re: Eyeballs needed on new reference counted pointer template
View as plain text  
On 29/11/2007, Warren Young <mysqlpp@stripped> wrote:
>   And in
> the assign(T*) case, I'm pretty sure assigning the same pointer will
> result in a double-delete.  I've added explicit checks to both assign()
> overloads.

Forgot to answer this bit ... that can only happen as a result of a
stupid programming error, you'd have to say:   p1.assign( p2.get() )
so it's pretty obvious you've just made p1 and p2 own the same
resource, but without sharing a refcount. If recountedptr is an
implementation detail, I think it's safe to assume you won't be doing
that yourself and users can't do it anyway.

I probably should have added comments to explain some of the code ...
I've been deep in the guts of shared_ptr for a few months and forget
that it's not all obvious.  Of course there may be bugs in the code,
but the checks for self-assignment were left out by design not
forgetfulness.

Jon
Thread
Re: Eyeballs needed on new reference counted pointer templateWarren Young29 Nov
  • Re: Eyeballs needed on new reference counted pointer templateJoseph Artsimovich29 Nov
    • Re: Eyeballs needed on new reference counted pointer templateWarren Young29 Nov
      • Re: Eyeballs needed on new reference counted pointer templateJonathan Wakely30 Nov
        • Re: Eyeballs needed on new reference counted pointer templateWarren Young1 Dec
  • Re: Eyeballs needed on new reference counted pointer templateJonathan Wakely30 Nov
    • Re: Eyeballs needed on new reference counted pointer templateWarren Young1 Dec
  • Re: Eyeballs needed on new reference counted pointer templateJonathan Wakely30 Nov
    • Re: Eyeballs needed on new reference counted pointer templateWarren Young1 Dec