cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: proposal: curl_easy_setopt should copy argument strings

From: Hisseine Dj. <djandabri_at_sympatico.ca>
Date: Sun, 26 May 2002 09:48:35 -0400

> I made it this way deliberately from the beginning, as it makes libcurl do
> less malloc()/free() operations. In many cases they won't be needed, since
> the application will have the data kept around anyway. By giving the
> application the responsibility, we get the lowest possible number of
malloc()
> calls.
>

I agree with this idea, because using strdup() function will create a new
problem if the user application use a lot of curl_easy_setopt and there is
insufficient memory.

I am using curl_easy_setopt in my application and I didn't notice anything
wrong.

Hisseine

----- Original Message -----
From: "Daniel Stenberg" <daniel_at_haxx.se>
To: "Vladimir Tsichevski" <wowa1_at_online.ru>
Cc: "libcurl Mailing list" <curl-library_at_lists.sourceforge.net>
Sent: Sunday, May 26, 2002 9:32 AM
Subject: Re: proposal: curl_easy_setopt should copy argument strings

> On Sun, 26 May 2002, Vladimir Tsichevski wrote:
>
> > Perusing the libcurl sources I noticed that curl_easy_setopt just stores
> > the pointers to its char* arguments. So everyone who uses that procedure
> > should maintain the storage for that strings.
>
> Yes, that has been the case since day one and is also documented in the
> curl_easy_setopt man page. Shouldn't come as a surprise! ;-)
>
> > Had curl_easy_setopt() copy the strings with strdup() would solve that
> > problem.
>
> Is this really a problem?
>
> I made it this way deliberately from the beginning, as it makes libcurl do
> less malloc()/free() operations. In many cases they won't be needed, since
> the application will have the data kept around anyway. By giving the
> application the responsibility, we get the lowest possible number of
malloc()
> calls.
>
> But I'm open for listening to other persons' opinions on this issue.
>
> --
> Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
>
>
> _______________________________________________________________
>
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
>
>
>

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
Received on 2002-05-26