F
finding83
why is it a problem if we have a huge piece of code between new and
delete of a char array.
example:
http://www.efnetcpp.org/wiki/Heap_Corruption
void this_is_bad() /* You wouldn't believe how often this kind of
code can be found */
{
char *p = new char[5]; /* spend some cycles in the memory
manager */
/* do some stuff with p */
delete[] p; /* spend some more cycles, and create an
opportunity for a leak */
}
delete of a char array.
example:
http://www.efnetcpp.org/wiki/Heap_Corruption
void this_is_bad() /* You wouldn't believe how often this kind of
code can be found */
{
char *p = new char[5]; /* spend some cycles in the memory
manager */
/* do some stuff with p */
delete[] p; /* spend some more cycles, and create an
opportunity for a leak */
}