Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Cleanup for heap arrays

C++ arrays are allocated on the heap using operator new[]. The cleanup rules for such arrays are as follows:

Note on compiler behaviour

Of the compilers used with Symbian OS, Metrowerks CodeWarrior is the most sensitive to the rules for array deletion. If an array is deleted with a simple delete rather than delete[], then a USER 42 panic (invalid heap cell) can occur.

(This panic in fact occurs for arrays in which the class has either a constructor or a destructor. For such arrays, CodeWarrior reserves space at the start of the array storage to hold the number of elements in the array: this means the first heap cell is not the start of a deletable object. GCC and MSVC C++ only reserve such extra space if the class has a destructor.)