cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_multi_perform and write_callback

From: Jeroen Ooms <jeroenooms_at_gmail.com>
Date: Mon, 17 Nov 2014 20:15:12 -0800

On Mon, Nov 17, 2014 at 3:21 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> Unfortunately, there is no way to alter libcurl behavior in such a way. If
> libcurl for example gets data that expands to 3x the buffer size, it will
> call the write callback three times to let the application consume all data
> accordingly.

Thank you. So there is really no avoiding realloc.

An additional question: in the getinmemory.c example [1], why does
realloc allocate 1 byte more than needed and than sets it to 0 at the
end of the callback? The help page for CURLOPT_WRITEFUNCTION says "The
data passed to this function will not be zero terminated!". What is
the benefit of adding a 0 manually?

[1] http://curl.haxx.se/libcurl/c/getinmemory.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-11-18