HI > Hi > > > Max wrote: > > > BITMAPINFO * pBmi = 0; > > > pBmi = (BITMAPINFO*) new BYTE [ sizeof (BITMAPINFO) + (sizeof > (RGBQUAD) * > > > 8)) ]; > > > > Ah yes when you look at it that way... But to be honest this doesn't > > look much better to me than the malloc() way (that is not to say that > > this solution is not good, just that in these cases using new/delete > > over malloc/free doesn't seem as compelling any more). > > Yes, but you're not exception safe, you'll get a leak. So what you > should really have is:
Of course it's not exception safe - this is MSVC and that doesn't stick to the standard - new doesn't throw exceptions. > > typedef std::auto_ptr< BITMAPINFO > BITMAPINFOPTR; > BITMAPINFOPTR pBmi( new BYTE [ sizeof (BITMAPINFO) + (sizeof (RGBQUAD) > * 8)) ]); > I wrote my own type of smart ptr thanks. Regards Max
