cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Avoid copying data in CURLOPT_WRITEFUNCTION callback

From: Konstantin Miller <konstantin.miller_at_googlemail.com>
Date: Mon, 13 Feb 2012 13:56:50 +0100

An interface as suggested by Yehezkel would be really great! It would give
the application the flexibility to implement its own memory management. It
still would be very helpful, even if the minimum buffer size would be 2 x
16K, as pointed out by Daniel.

I think that if you are targeting a video streaming application with
bit-rates of several megabit per second, the speed gain would be
significant.

Konstantin

On Mon, Feb 13, 2012 at 13:48, Lars Nilsson <chamaeleon_at_gmail.com> wrote:

> 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
>

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