The normal way to assign memory to a pointer (using nothrow):
1 2 3 4 5 6
int *p = NULL; //declare pointer
p = new (nothrow) int [SIZE]; //assing memory
if (p == NULL) //check or assigment failed
{
returnfalse; //handle the error
}
There is no need to free the memory, since there is no memory reserved in the first place.
Try to avoid confusing names like "data_" and "data", because this will make your code harder to understand for others/yourself when you come back to it. And don't use goto's.