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 16:40:44 +0200 (CEST)

On Tue, 11 Oct 2005, Michael Mastroianni wrote:

> Why not use the string directly in the callback, something like this
>
> size_t WriteMemoryCallbackStdString(void *ptr, size_t size, size_t
> nmemb, void *data)
> {
> register int realsize = size * nmemb;
> string & contents = *(string *)(data);
> contents.append((char *)ptr,realsize);
> return realsize;
> }

That is of course perfectly possible, but this suggestion does exactly that
extra copy that Bharath Devanathan wanted to avoid.

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