delete [] char *, memory issues
<p>I have a global pointer variable</p>

<pre><code>char* pointer = new char[500];
/* some operations... */
</code></pre>

<p>there is a seperate FreeGlobal() function that does free up the pointer as below:</p>

<pre><code>delete[] pointer;
</code></pre>

<p>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. </p>

<p>Is there a way to check the pointer variable before calling delete [] again? What are the work arounds? Is this a bad practice?</p>

<p>Thank you. </p>
