(I didn't get Paul's first message on malloc/free yet through the list, I got it from the archive - I just copied it below)

> > CString str("hello");
> > char* tmp = (char*)malloc(str.GetLength() + 1);
> > wcstombs(tmp, str, str.GetLength());
> > LibraryFuncCall(tmp);
> > free(tmp);
> malloc? free? This is C++ isn't it? Shouldn't you be suing new and
> delete? What if wcstombs or LibraryFuncCall trhow an exception? You'd
> get a memory leak! Try using boost's (www.boost.org) array pointer and
> new and delete instead.

Well it is C++ but new and delete use malloc and free internally anyway. And wcstombs and LibraryFuncCall are C functions so they cannot throw exceptions. I like boost but as an exercise I'm trying to do this using ATL/WTL/Win32 as much as possible (for example, I also choose MSXML through COM over using XercesC, although I have plenty of experience with Xerces and none with msxml). I'm just saying that for this project I'm trying to go all the way Microsoft so that I can decide later on whether I liked it or not. It has advantages of course - documentation is all in the same place, it's all installed when you install Visual Studio, ... Anway, that was just some background info :)

cheers,

roel




Paul Grenyer wrote:

Hi


It's a shame you had not used MFC's CString - it has a (const char *)
extraction operator to get out a char * even under Unicode conditions (and an (LPCTSTR) extraction operator for getting proper Unicode characters, as you would use in most other places).


Not really as then the MFC runtime libraries would have to be dragged into the ATL application. Jason, you know what I think of the MFC. ;-)

In fact I'm not even keen on ATL's CString. OP, why aren't you using std::string?

Regards
Paul

Paul Grenyer
Email: [EMAIL PROTECTED]
Web: http://www.paulgrenyer.co.uk

Have you met Aeryn: http://www.paulgrenyer.co.uk/aeryn/?
Version 0.3.0 beta now available for download.



_______________________________________________
msvc mailing list
[EMAIL PROTECTED]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription 
changes, and list archive.





Reply via email to