curl-library
RE: WriteMemoryCallback (was "(no subject)")
Date: Wed, 18 Sep 2002 16:54:27 -0400
My class lets call it A looked like this:
class A {
A();
size_t curl_write_data(void *buffer, size_t size, size_t nmemb, void
*userp);
};
then in implementing
size_t A::curl_write_data(void *buffer, size_t size, size_t nmemb, void
*userp) {
// do some memory stuff here allot like the example from the curl
site
return whateversize_t;
}
This cause it to blow up. BUT after doing what you suggested. I moved my
definition of curl_write_date out of my class and wrapped it with extern "C"
and then removed the A::curl_write_data to be curl_write_data, all was
happy. Only 6 hours wasted on this :) Thank goodness for mailing
lists!!!!!!!
Thanks so much.
-----Original Message-----
From: RBramante_at_on.com [mailto:RBramante_at_on.com]
Sent: Wednesday, September 18, 2002 4:23 PM
To: curl-library_at_lists.sourceforge.net
Subject: WriteMemoryCallback (was "(no subject)")
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
-------------------------------------------------------
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