cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curlopt_writefunction Questions

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Tue, 13 Apr 2004 08:06:33 +0200 (CEST)

On Mon, 12 Apr 2004, Monica Lau wrote:

> I'm using the curlopt_writefunction option to pass the response data from
> the HTTP server to a string in my application directly. I tried the example
> in the "getinmemory.c" code, and it worked. However, I realized that
> multiple calls to the write function may be made per a single transaction.
> So, in this case, I actually need a global string and keep appending to this
> string whenever the write function is called. Otherwise, I end up with a
> string that gets overwritten. So, my first question is: Is keeping a global
> string the correct way of handling this issue?

I suggest you read that "getinmemory.c" example source code once more. It
solves the problem and it does not use a global variable.

-- 
     Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
      Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-04-13