cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Does CURL_OPT_URL copy its data?

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Thu, 24 Mar 2011 22:20:46 -0700

On Fri, Mar 25, 2011 at 12:26:22AM -0400, richardcavell_at_mail.com wrote:
> When setting the URL with:
>
> CURLcode res = curl_easy_setopt (h->curlhandle, CURLOPT_URL,
> szloginurl);
>
> Is it necessary that szloginurl be in scope when curl_easy_perform()
> is run?

This is documented in the curl_easy_setopt man page:

       Strings passed to libcurl as 'char *' arguments, are
       copied by the library; thus the string storage associated
       to the pointer argument may be overwritten after
       curl_easy_setopt() returns. Exceptions to this rule are
       described in the option details below.

       Before version 7.17.0, strings were not copied. Instead
       the user was forced keep them available until libcurl no
       longer needed them.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-03-25