curl-library
Re: curlopt_writefunction Questions
Date: Tue, 13 Apr 2004 09:42:46 -0700 (PDT)
Oh -- stupid mistake again! Thank you for pointing
this out. Now the getinmemory.c write function makes
sense -- I had modified it earlier because I didn't
know that the write function gets called multiple
times. I tried the code again with "realloc()" and it
works!
Thanks again,
Monica
--- Daniel Stenberg <daniel-curl_at_haxx.se> wrote:
> 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
__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/
Received on 2004-04-13