curl-library
Re: CURLOPT_WRITEFUNCTION - cannot make it working...
Date: Sat, 4 Jun 2011 22:58:59 -0700
There has to be something crazy going on because if i'm reading this
correctly... if what you said is how it worked for everyone else (i
know it isn't how it works for me, or how the docs say it should
work), there would be some really BIG problems with using libcurl :P
your 3.07e+9 value sounds familiar, i don't know if gcc does this too,
but in MSVC, in debug, deleted memory gets set to all d's (in hex - ie
0xdddddddd), and uninitialized allocated memory gets set to all a's.
the 3.07e+9 i think i recall seeing before as either the float
interpretation of all a's or all d's. you might check out the raw
bytes in hex and see if it is either. if so that could give a hint to
what the core issue is.
On Sat, Jun 4, 2011 at 10:48 PM, Paolo Piacentini
<paolopiace_at_hotmail.com> wrote:
> I finally made it working. The big problem is that, with NO doubt,
> curl_easy_perform changes (corrupts?) the initialization of the vars in the
> user data structure (say data_struct) passed to CURLOPT_WRITEDATA.
> Therefore, the write-back function defined with CURLOPT_WRITEFUNCTION
> *cannot* rely on the user initialization.
>
> Interestingly, curl_easy_perform changes the initialization of any size_t
> var in the data_struct to a random value around 3.07e+9 *. Therefore, the
> first time the write-back function is called, it sees such value assigned to
> all size_t variable of data_struct.
>
> Hence, in order to make the write-back function to initialize the storing of
> data, I'm checking a (any) size_t vars in data_struct. If it's higher than
> 3e+9 it means that the write-back function has been called for the very
> first time.
>
> After that, curl_easy_perform leaves the data_struct alone, with some
> exception: I noticed that it resets all the vars in the data_struct
> (literally!) sometimes/somehow while receiving the data of the thread. But
> this might be a design feature as it does not create problems.
>
> (*) I'm on Ubuntu 10.04; g++ 4.4.3; libcurl/7.19.7 GnuTLS/2.8.5 zlib/1.2.3.3
> libidn/1.1
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-06-05