abraker95 / tanks

2D arcade top-view shooting game
1 stars 0 forks source link

fix memory leaks #19

Closed ghost closed 9 years ago

ghost commented 9 years ago

every element which is erased from a vector of pointers should be deleted. see here: http://stackoverflow.com/questions/6353149/does-vectorerase-on-a-vector-of-object-pointers-destroy-the-object-itself

ghost commented 9 years ago

the erased element is deleted in the erase function:

From http://www.cplusplus.com/reference/vector/vector/erase/:

Removes from the vector http://www.cplusplus.com/vector either a single element (position) or a range of elements ([first,last)).

This effectively reduces the container size http://www.cplusplus.com/vector::size by the number of elements removed, which are destroyed.

ghost commented 9 years ago

oh ok nevermind. Read the other link you sent me:

Removes from the vector container and calls its destructor but If the

contained object is a pointer it doesnt take ownership of destroying it.

ghost commented 9 years ago

fixed