I have a global pointer variable
char* pointer = new char[500];
/* some operations... */
there is a seperate FreeGlobal() function that does free up the pointer as below:
delete[] pointer;
First time when the function is called, it actually frees up the memory and now the pointer is a bad pointer. But when we call this more than once, it throws an exception.
Is there a way to check the pointer variable before calling delete [] again? What are the work arounds? Is this a bad practice?
Thank you.