cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_slist_free_all Issue

From: Laurent Taurines <ltaurines_at_hi-stor.com>
Date: Fri, 01 Dec 2006 17:24:40 +0100

Daniel Stenberg wrote:
> On Fri, 1 Dec 2006, Laurent Taurines wrote:
>
>> It seems I was right. After calling curl_slist_free_all(slist) slist
>> must be set to NULL otherwise it does not work as expected.
>
> After you call that function, libcurl has nothing to do with it (==
> the memory it pointed to) so you can do whatever you want with it.
except that if we want to reuse slist we must set it to NULL after every
call to curl_slist_free_all(slist) or before any call to
curl_slist_append() (not only the first time).
>
>> I do not know if this should be considered as a bug but it seems to
>> me that curl_slist_free_all(slist) should set slist to NULL.
>
> No, it can't and it shouldn't.
>
> I rather suspect your problem is that you haven't initialized the
> pointer to NULL when you call curl_slist_append() the first time.
It was the first time but not the second time after calling
curl_slist_free_all(slist).

Laurent.
Received on 2006-12-01