cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Basic Question on read callback ()?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 30 Jan 2008 12:29:59 +0100 (CET)

On Wed, 30 Jan 2008, Ramprakash Jelari thinakaran wrote:

> curl_easy_setopt(easyhandle, CURLOPT_READFUNCTION, read_function);
>
> in the read_function (), the first parameter is void *ptr, do we have to
> allocate the heap memory for this ptr explictily?.. i m trying to copy 1MB
> of data for each read, from total of 2GB file.

You don't need to allocate anything.

You need to copy data to that buffer it points to, and it should be no more
than (size * nmemb) bytes but of course preferably exactly that much for
maximum throughput.

Like in this example:

         http://curl.haxx.se/lxr/source/docs/examples/anyauthput.c

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2008-01-30