cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: removing a set option (curl_easy_setopt) once it has been set

From: Steve Holme <steve_holme_at_hotmail.com>
Date: Mon, 12 Mar 2012 15:41:29 +0000

On Mon, 12 Mar 2012, Steve Holme wrote:

> As Curl calls strdup() when setting string variables this should free
> the previous memory and then strdup() should fail and return a
> null pointer (thus setting it back to its original state) ;-)

My curiosity got the better of me so I took a look at curl_easy_setop(),
Curl_setopt() and eventually setstropt() in more detail to see what actually
happens and...

It does indeed call free (but it uses Curl_Safefree() so it will set the
variable to NULL) but for safety reasons I guess, it doesn't call strdup()
if the pointer you pass in is NULL so yes it does unset the option for you
;-)

Steve

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-12