cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: proposal: curl_easy_setopt should copy argument strings

From: J. Cone <jcone_at_eservglobal.co.nz>
Date: Mon, 27 May 2002 09:01:53 +1200

An application which sets the same option repeatedly with malloced memory
could give itself grief. If there was an easy way to tell libCurl whether
to free this configuration item, that would be nice, but I don't think it's
worth adding an extra argument that would break all existing code. Is
there ever going to be a posix call to ask 'Is this the pointer to the
start of a malloc?"

At 09:48 26/05/2002 -0400, Hisseine Dj. wrote:
> > 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

_______________________________________________________________

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