I am trying to allocate a two dimensional array dynamically and then after use, delete it. The code looks something like this:
func(char* pszError)
{
//Initialize
char ** ptr = new char*[1];
// Some copying stuff in ptr[0]
ptr[0] = new char[strlen(psError) + 1];
strcpy(ptr[0], strlen(pszError) + 1, pszError);
delete[] ptr[0];
delete[] ptr;
return;
}
This looked harmless to me and shouldnt have given error. However, at the point delete[] ptr; its throwing me access violation.
Can anyone help me. I have done enough head banging on this.
std::vectoror Boost.MultiArray.ptr[0]=new char[10]; ptr[0] = new char[strlen(psError) + 1];-> at least memory leak...