from the C++ FAQ:
TITLE: Using delete [] versus delete The extra "[]" warns the compiler that there is a whole array of objects here so that P's destructor must be called on each element of the array rather than just on P itself (which would be equivalent to the first element only).
This commit is contained in:
parent
5c99b9308c
commit
c8f9fc0ae4
2 changed files with 3 additions and 3 deletions
|
@ -134,7 +134,7 @@ FGDialog::~FGDialog ()
|
|||
for (i = 0; i < _char_arrays.size(); i++) {
|
||||
for (int j = 0; _char_arrays[i][j] != 0; j++)
|
||||
free(_char_arrays[i][j]); // added with strdup
|
||||
delete _char_arrays[i];
|
||||
delete[] _char_arrays[i];
|
||||
}
|
||||
|
||||
// Delete all the info objects we
|
||||
|
|
|
@ -217,7 +217,7 @@ FGMenuBar::~FGMenuBar ()
|
|||
for (i = 0; i < _char_arrays.size(); i++) {
|
||||
for (int j = 0; _char_arrays[i][j] != 0; j++)
|
||||
free(_char_arrays[i][j]); // added with strdup
|
||||
delete _char_arrays[i];
|
||||
delete[] _char_arrays[i];
|
||||
}
|
||||
|
||||
// Delete all the callback arrays
|
||||
|
@ -225,7 +225,7 @@ FGMenuBar::~FGMenuBar ()
|
|||
// plib.
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Deleting callback arrays");
|
||||
for (i = 0; i < _callback_arrays.size(); i++)
|
||||
delete _callback_arrays[i];
|
||||
delete[] _callback_arrays[i];
|
||||
|
||||
// Delete all those bindings
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Deleting bindings");
|
||||
|
|
Loading…
Add table
Reference in a new issue