cURL / Mailing Lists / curl-library / Single Mail


Re: Basic Question on read callback ()?

From: Daniel Stenberg <>
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:

  Commercial curl and libcurl Technical Support:
Received on 2008-01-30