cURL / Mailing Lists / curl-library / Single Mail


RE: Allocated curl_easy_setopt() strings

From: Daniel Stenberg <>
Date: Sun, 29 Jul 2007 15:43:33 +0200 (CEST)

On Fri, 27 Jul 2007, Daniel Stenberg wrote:

> Great. It does cause a little (easily fixed) warning in lib/url.c, but more
> importantly it segfaults test 512. I'll dig some more on exactly why within
> a day or two.

Ok, I found and fixed the problem (in Curl_dupset()), and I've attached the
full patch with my fix in it.

But I had another thought on the approach: since there are now no less than 30
strings that are allocated and copied, and each string is dealt with in
several places in the code. Wouldn't it make sense to make a string array
instead and access each individual string using an enum?

I mean like this (pseudo-code to display the concept in my mind):

   enum {

   /* to extract a single string in the code, we get it from the array */
   char *netrc = data->set.strings[ enum ];

   /* and thus when we set this string in lib/url.c:Curl_setopt() we'd do: */
   result = Curl_setstropt(&data->set.strings[STRING_NETRC], ... );

Since then we can use a simple loop in Curl_dupset(), and dupset would also
automatically work without changes when we add more strings in the future.

What do you (meaning everyone, not just Patrick) say?

  Commercial curl and libcurl Technical Support:

Received on 2007-07-29