cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Prevent copying of data between curl buffer and user provided buffer

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Tue, 11 Oct 2005 10:31:11 +0200 (CEST)

On Tue, 11 Oct 2005, Bharath Devanathan wrote:

>> If there would be such a function (or functionS - plural - since there is
>> an equivalent case for uploads) I would rather have a way for the app to
>> repeatedly provide buffer space for the next downloaded chunk to get stored
>> into, and for each write to the buffer it would call the callback to allow
>> the application to provide more buffer(s).
>
> Good idea. I would extend that a bit further and also provide an api where
> the app provides a single pointer and a buffer pool or simply redefines
> realloc.

If libcurl would call a callback when writing to the buffer (like today, but
relieving the app from having to copy the actual data), the app could then
easily realloc() the original buffer and then point to the new buffer space
(and size) for libcurl to store more data into. It would make libcurl agnostic
to exactly how or where the buffer is, just that there is a buffer of size N
to store data into.

>> You feel up to working on such a feature?
> Yes, how can i get started?

I would suggest something along this route:

1. Figure out the API properly. What options do we need to add? What functions
    do we need to add and how do they all work?

2. Write a simple application that uses the API/options in 1)

3. Implement the buffer concept into libcurl.

4. Convert the app in 2) into a test case (see other test cases in the 5XX
    range for many useful examples to cut'n paste from).

Of course I'll be around and will assist as much as I can if you just keep the
list posted with progress info etc.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-10-11