Okay so I'm trying to replace all my malloc/free things with new/delete like I should. Now, how do I do the following:


BITMAPINFO* bmi;
bmi = (BITMAPINFO*)malloc(sizeof(BITMAPINFO) + (sizeof(RGBQUAD) * 8));

in a C++-ish way?

cheers,

roel


Paul Grenyer wrote:

Hi

Just some observations:


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.

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