curl-users
Re: response data received from server
Date: Sun, 14 Sep 2003 14:02:55 +0200 (CEST)
On Fri, 12 Sep 2003, Jerry G. Chiuan wrote:
> I found an interesting thing regarding data (pointed by ptr ) passed into
> the WRITEFUNCTION callback:
>
> size_t write_to_chunk(void *ptr, size_t size, size_t nmemb, void *data)
>
> Originally, I worry about how long the data would be there without being
> over written ( <- you used to tell me that the buffer is reused )
It is.
> "You have to copy the data. When you return from the callback, the buffer
> will be re-used for other purposes." (<- this is what you mentioned in
> previous email )
Yes.
> But, I found that the data will be there after the callback returns, until
> next response comes in and it gets overwritten It is alive long enough in my
> case, I can copy data out of the buffer "before the next response is
> received" ( not that fast before the callback returns) I thought I have to
> copy data out of the buffer "right away".
If you decide to take chances, sure you can do anything you want. But don't
blame libcurl when it stops working in the next release or something. Relying
on undocumented features or side-effects is not what I would recommend.
-- Daniel Stenberg -- curl: been grokking URLs since 1998 ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sfReceived on 2003-09-14