Deleting Global allocated memory in C++
<p>Today i tried to create global pointer:</p>

<pre><code>int *map = new int[M2*N2];
</code></pre>

<p>then i tried to delete this in main() function:</p>

<pre><code>delete[] map;
map = NULL;
</code></pre>

<p>But after executing all program it gives error:</p>

<pre><code>free(): invalid next size (fast)
</code></pre>

<p>So, Is it possible to create such pointer and then delete it anywhere else?</p>

<p><strong>Edit</strong></p>

<p>Its Fixed.</p>

<p>M2 was M+1 (M was limit for array), After using M2=M+10 it worked.</p>

<p><strong>Thanks to all...</strong></p>
