|
From: Patrick J. L. <lop...@gm...> - 2012-10-02 14:34:02
|
On Tue, Oct 2, 2012 at 5:55 AM, jody <jod...@gm...> wrote:
>
>
> ---------------------------------
> void CellGrid::destroyGrid() {
>
> if (m_apCells != NULL) {
> for (coord j = 0; j < m_iNumCells; j++) {
> if (m_apCells[j] != NULL) {
> delete m_apCells[j];
> }
> }
> delete[] m_apCells;
> }
>
> //.... other stuff unrelated to m_apCells
> }
This is not related to your problem, but... In C++ -- all versions
ever, standard or otherwise -- calling "delete" on a NULL pointer is
guaranteed to be a no-op. So there is never a need to check for NULL
before calling "delete". Doing so makes your code run slower, makes
it harder to read, and makes the reader wonder whether the author
simply does not know C++ or is trying to work around some obscure bug
in some compiler.
- Pat
|