cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curlpp mailing list Archives

Re: [cURLpp] setOpt using a pointer to an option - do we really need it?

From: Jean-Philippe Barette-LaPierre <jpbarrette_at_gmail.com>
Date: Fri, 14 Nov 2008 14:31:05 -0500

On Fri, Nov 14, 2008 at 1:09 PM, Piotr Dobrogost <curlpp_at_2008.autoera.pl>wrote:

> Jean
>
> What is the reason for allowing to set an option using a pointer?
> I think that having a version with reference is enough. The version with
> pointer is not needed and brings problems with memory management into the
> library.
>

from example01.cpp:

      myRequest.setOpt(cURLpp::Options::Url("example.com"));

      // Note that the previous line wasn't really efficient
      // because we create the option, this option is duplicated
      // for the request and then the option destructor is called.
      // You can use this instead:
      myRequest.setOpt(new cURLpp::Options::Url("example.com"));
      // Note that with this the request will use directly this
      // instance we just created. Be aware that if you pass an
      // Option pointer to the setOpt function, it will consider
      // the instance has its own instance. The Option instance
      // will be deleted when the request will be deleted, so
      // don't use the instance further in your code.

However, I would change
 setOpt(Option *)
to
 setOpt(auto_ptr<Option>)

>
> Regards
> Piotr Dobrogost
> _______________________________________________
> cURLpp mailing list
> cURLpp_at_rrette.com
> http://www.rrette.com/mailman/listinfo/curlpp
>

_______________________________________________
cURLpp mailing list
cURLpp_at_rrette.com
http://www.rrette.com/mailman/listinfo/curlpp
Received on 2008-11-14

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET