curl-library
Re: Problem caused by CURLDEBUG
Date: Mon, 23 Oct 2006 00:11:55 +0200 (CEST)
On Sun, 22 Oct 2006, James Housley wrote:
> The default mode of CURLDEBUG is to map free() to curl_dofree(), which is
> fine most of the time. However, if an external library does memory
> allocation it is not possible to free the memory without an error or
> warning.
Sure there is, you can use (free)(ptr). But of course there's been no NO need
for such a call yet, so I think that's a fine reason for free() to work as it
does.
I'd say that the best approach is to add wrappers for the new memory
allocating functions too, so that the memory leak/track system works for these
too.
Are you referring to some libssh2 calls?
> Lets take some very, very simple code.
>
> {
> char *str;
> asprintf(&str, "A simple print\n");
> free(str);
> }
Yes sure, but you should never call this function from within libcurl.
> The problem I ran into was a library, on request, allocating a buffer for an
> error string.
Then we should make a wrapper for libcurl that makes it return a pointer that
curl_dofree() can free(). That way we can also make sure that we never leak
memory, which I consider a very valuable help.
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2006-10-23