cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_callback

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 30 Dec 2013 10:36:38 +0100 (CET)

On Mon, 30 Dec 2013, karan tandel wrote:

Hi, and thanks for your interest in curl. Please be aware that you're talking
about libcurl, which is much better done on the dedicated curl-library list!
I'm cc'ing my response over there so please take follow-ups to that list.

> As per my understanding when libcurl receives http response bodys data, it
> internally malloc data, fill the response in it and provides that data in
> data callback. Now in that callback If I want to further use that data I
> have to malloc that data size and save that data. So for whole process, two
> times malloc and data copy is being done. I want to reduce it to one for
> better performance. Is there any way I can do that? Any pointers regarding
> this problems are very much welcome.

First, libcurl doesn't do that first malloc you talk about so your
understanding seems to be incorrect, and then your application doesn't *have
to* malloc for every callback function call. Thus, you can easily go down to
less than one malloc per data chunk.

We've discussed a "zero copy" interface many times but nobody ever pulled it
through all the way and I personally have yet to see a use case where the
extra copy actually matters enough to warrant the extra logic introduced to
support such an interface.

Is your concern here actually based on some metrics or performance
measurements that show that libcurl is too slow in some circumstance or that
you need to do more with less system calls somehow? If so, can you please
share such data with us?

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-12-30