Just recently I switched the language of my project to use C++ from C. With C, I used malloc and after that I check if malloc was successful but with C++, I use \'new\' to a
You'll still need to check for a memory allocation failure.
Either
scoped_array buf; try { buf.reset( new char[MAX_BUF] ); } catch( std::bad_alloc& ) { // Handle the failure }
Or
scoped_array buf( new(std::nothrow)char[MAX_BUF] ); if( buf.get() == NULL ) { // Handle the failure }