On Wed, Feb 2, 2011 at 6:21 AM, Nelson, Erik - 2
<[email protected]> wrote:
> Dean wrote:
>>
>> Why is copying into a string a problem in the first place?
>>
>
> It's not... you were talking about the extensively documented problem of 
> sending binary as 7-bit clear on the internet- that seems unrelated to 
> whether or not the netlib container is a std::string or something else.
>

Right, so why are we talking about this again? :D

>
>>
>>>> Erik wrote:
>>>>> auto_ptr<MyObject> obj(new MyObject);
>>>>> response << body(obj);
>
> Dean wrote:
>> >> Uh oh, this is dangerous because the user can use the obj right
>> after the data is passed to the response.
>
> Erik wrote:
>>> Nope- the auto_ptr will be cleared when the ownership transfers to
>>> the response, right?
>
>
> Dean wrote:
>> Well, after the `response << body(obj)` line, obj is still accessible
>> to the user. It's not guaranteed that the user will do this line at
>> the end of the handler body.
>
> Not so.  obj is not accessible if ownership has been transferred to the 
> response.  Two auto_ptrs can't refer to the same object.
>

See this code:

  std::auto_ptr<Foo> f(new Foo);
  response << body(f); // which would never happen, if I can do
anything about it... ;)
  f->bar(); // and here you get a segfault and angry users. ;)

Which is exactly what I want to avoid if I can help it. :)

-- 
Dean Michael Berris
about.me/deanberris

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Cpp-netlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel

Reply via email to