cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Saving data received from http server

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 12 Nov 2010 14:02:17 +0100 (CET)

On Fri, 12 Nov 2010, arnuld uttre wrote:

>> See http://curl.haxx.se/libcurl/c/getinmemory.html
>
> (1) is it necessary to call CURLOPT_WRITEDATA after CURLOPT_WRITEFUNCTION.
> Can't CURLOPT_WRITEFUNCTION be used alone ?

CURLOPT_WRITEFUNCTION sets the function that libcurl will call.
CURLOPT_WRITEDATA is used to set the pointer that the function gets in its
fourth argument. They're both needed to get this right.

> (2) Why not use malloc() and for(;;) loop with index counting like I have
> used rather than copying raw memory ?

Who can do it in several different ways, getinmemory.c is just an example and
you are free and encouraged to change every tiny detail you think should be
different.

However, memcpy() is likely to be MUCH faster than any for() loop that would
copy the same memory in a slower manner...

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