I regard using
char* str = new char[sz];
as deprecated/anachronistic.
If you do string handling, try using
std::string str = ...;
or if you work on raw memory try using
std::vector<char> mem;
. Both are smart enough to handle the dynamic memory in a decent way, i.e. you do not have to care about new/malloc/calloc/strdup/... and delete/delete[]/free/...
See
http://www.cplusplus.com/reference/string/string/[
^] and
http://www.cplusplus.com/reference/vector/vector/[
^].
Cheers
Andi