Freeing a List of Pointers
How to free a list of pointers properly:
list<Entity*> l = ...;
while(!l.empty()){
delete l.front();
l.pop_front();
}
Just calling l.clear()
is insufficient and will result in memory leaks.
How to free a list of pointers properly:
list<Entity*> l = ...;
while(!l.empty()){
delete l.front();
l.pop_front();
}
Just calling l.clear()
is insufficient and will result in memory leaks.