cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: getinmemory.c sample crashes with TCHAR

From: Itamar Syn-Hershko <itamar_at_divrei-tora.com>
Date: Sun, 12 Nov 2006 23:03:09 +0200

On Sun, 12 Nov 2006, Daniel Stenberg wrote:

> If you make it crash by changing the application, I can't but assume that
your
> code is the reason for the crash so if you want help I think you'd rather
show
> us your code instead.

I hardly changed the code supplied by you. What I did is as follows:

1. Take the functions from getinmemory.c and plant them in my code, taking
the lines from main() and putting them in my main function.

2. Replace the 2 occurences of char* with TCHAR* (one at MemoryStruct and
one at WriteMemoryCallback). My project is Unicode enabled, what makes
TCHAR* a wchar_t*.

3. Where you got the line saying "Do something nice with it!", I have this
line:
szData.Format(_T("%S"), chunk.memory);
Where szData is a Cstring object (MFC), and Format() is a parallel function
of printf used to format a CString.

4. After compiled, it crashes with AV at this line: mem->memory[mem->size] =
0;. I'm 100% it will crash at your end if you'll compile the same code with
wchar_t*.

Itamar.
Received on 2006-11-12