Paul Grenyer wrote:
Yes, but you're not exception safe, you'll get a leak. So what you should really have is:
typedef std::auto_ptr< BITMAPINFO > BITMAPINFOPTR;
BITMAPINFOPTR pBmi( new BYTE [ sizeof (BITMAPINFO) + (sizeof (RGBQUAD) * 8)) ]);
Then you'd be exception safe and you don't have to worry about cleaning up either. However, std::auto_ptr is just plain wrong. You're better off with boost::scoped or boost::shared_ptr.

Aha yes exception safety. Indeed I think I'll use this approach (with shared_ptr of course). Thanks.


cheers,

roel





Reply via email to