curl-library
WriteMemoryCallback (was "(no subject)")
Date: Wed, 18 Sep 2002 16:23:12 -0400
It looks like WriteMemoryCallback is a member function of a C++ class. How
is this defined? It needs to have C linkage for the callback to work.
Normally when you want to callback into C++ member function, a C helper
function makes life easier, e.g.
/* header file */
extern "C"
{
size_t curl_write_data(void *buffer, size_t size, size_t nmemb, void
*userp);
}
/* impl */
size_t curl_write_data(void *buffer, size_t size, size_t nmemb, void
*userp)
{
MyClass* p = reinterpret_cast<MyClass*>(userp);
return p->write_data(buffer, size, nmemb);
}
You pass the 'this' into the CURLOPT_WRITEFILE argument and then your
helper function redirects it to the proper object member function.
Just a thought anyway. This is how I've setup the callbacks with C++ code
in the past and they work fine.
I have a issue with trying to get a call back function to work. For some
reason when WriteMemoryCallback is called a "The memory could not be read"
error occurs.
-------------------------------------------------------
This SF.NET email is sponsored by: AMD - Your access to the experts
on Hammer Technology! Open Source & Linux Developers, register now
for the AMD Developer Symposium. Code: EX8664
http://www.developwithamd.com/developerlab
Received on 2002-09-18