cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Avoid copying data in CURLOPT_WRITEFUNCTION callback

From: Lars Nilsson <chamaeleon_at_gmail.com>
Date: Mon, 13 Feb 2012 07:48:00 -0500

On Mon, Feb 13, 2012 at 7:39 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Mon, 13 Feb 2012, Yehezkel Horowitz wrote:
>
>> Currently each easy handle has its own 2 buffers with fixed size of 16K.
>>
>> This enforces the application that uses libcurl to copy the data when the
>> callbacks are called, since it will not be valid after the callback return.
>
>
> I understand perfectly.
>
> My point was rather: if you replace libcurl's static 16K allocation with it
> always asking the application to alloc 16K for each chunk that might come,
> then there's no gain in memory use...

Presumably the callback would return the same buffer (or an offset
into the buffer based on the range received so far) every time to
avoid reallocation, as hopefully (or there'll be trouble) the writer
callback is done with the content and the memory are is free to be
filled up with new content.

Lars Nilsson
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-02-13