cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: http headers free and multi

From: Mohun Biswas <m_biswas_at_mailinator.com>
Date: Sat, 14 Oct 2006 09:04:07 -0400

Brian Dessent wrote:
> If you do it by adding a new export you
> create a hard line in the sand that can never be crossed; you have to
> bump the ABI number and doom all your users to installing both libcurl3
> and libcurl4 for some indeterminate period of time, potentially years.

It's not my area of expertise but I've never had the impression that
*adding* an export requires a versioning bump. I can't see why it would.
Perhaps Daniel could clarify this aspect.

>> Notice that (a) there are two copies of 'errbuf' and (b) the freeing
>> code block is utterly opaque in terms of WHAT it's freeing. Whereas if
>> we free the result of
>>
>> curl_easy_getopt(CURLOPT_ERRORBUFFER);
>>
>> then the lifespan of the error buffer is better documented before a
>> single comment is written.
>
> You're kind of setting up a straw man here. OF COURSE there must be two
> copies of the pointer to errbuf (not two copies of errbuf),

Technically 'errbuf' is the pointer; that's why we say "char *errbuf".

> because if
> there weren't and the original pointer were still in scope then you
> could just free that. But since in your example the original "errbuf"
> pointer was an automatic variable it does not even exist by the time the
> second snippet gets called (assuming that the init was in a function
> that has returned), so it's not really fair to say that there are two
> copies.

You've misunderstood again. The automatic variable would be a *third*
copy if it stayed in scope. The value contained in the 'errbuf' pointer
is copied into the opaque CURL * struct in two places, one identified by
CURLOPT_ERRORBUFFER and the other by CURLOPT_PRIVATE.

MB
Received on 2006-10-14