cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_WRITEFUNCTION

From: Lars Nilsson <chamaeleon_at_gmail.com>
Date: Wed, 4 May 2005 13:21:22 -0400

On 5/4/05, Cris D Putnam <cdputnam_at_us.ibm.com> wrote:
>
> I am trying to put the HTML code into memory in a C++ class. I am copying
> the general idea of getinmemory.c . But my program crashes with this error:
>
> Run-Time Check Failure #0 - The value of ESP was not properly saved across a
> function call. This is usually a result of calling a function declared with
> one calling convention with a function pointer declared with a different
> calling convention.
>
> On these line of code:
> / send all data to this function
> curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION,
> WriteMemoryCallback);
>
>
> When called alone this->WriteMemoryCallback does not crash the program...
> So I have narrowed it down to CURLOPT_WRITEFUNCTION
> This line is just fine in a main mehod, but when I put it within a function
> of a .cpp class I guess the calling convention is different? How can I fix
> this?

Write a "C" function that serves as a wrapper function, and use
CURLOPT_WRITEFUNCTION and CURLOPT_WRITEDATA, and given your wrapper
function to the former, and a pointer to your class object to the
latter. Then call the member function on the class object from within
the wrapper function. I am assuming that having a static member
function without the notion of "this" is not what you're after.

Lars Nilsson
Received on 2005-05-04