OpenXcom Forum

Contributions => Programming => Topic started by: kevL on September 13, 2013, 11:30:48 pm

Title: memLeak when priming grenades?
Post by: kevL on September 13, 2013, 11:30:48 pm
I'm just learning c++ (don't laugh unless you want to)

i have a lot of experience with NwScript (don't underestimate it..)


So, in PrimeGrenadeState.cpp, I come across the destructor and notice it doesn't explicitly delete _title, _window, _bg, etc. Yet in other destructors, eg. Inventory.cpp, I notice that these 'new' subobjects are explicitly deleted. So i'm wondering:

is that a memory leak?


[ edit ] I'm guessing, not, because in BattlescapeState.cpp i see a bunch of 'news' that are also not explicitly deleted (yet some are..) in the destructor. Perhaps some of those subobjects are automatically deleted when the object itself is deleted...
Title: Re: memLeak when priming grenades?
Post by: SupSuper on September 14, 2013, 02:06:46 am
Yeah this tends to throw people off as Surfaces added to a State through add() are automatically handled by the base State destructor (just a convenient shortcut), but other elements still need to be manually destroyed.
Title: Re: memLeak when priming grenades?
Post by: kevL on September 14, 2013, 02:39:12 am
ok, thanks Sup.

will keep trudgin on then,