- Fix a memory leak with Sacrifice costs
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-06-25 13:20:27 +00:00
parent 71cc79b949
commit 3d414f74b3
3 changed files with 9 additions and 3 deletions
+1
View File
@@ -26,6 +26,7 @@ public:
MTGCardInstance * source; MTGCardInstance * source;
MTGAbility * action; MTGAbility * action;
ExtraCosts(); ExtraCosts();
~ExtraCosts();
void Render(); void Render();
int tryToSetPayment(MTGCardInstance * card); int tryToSetPayment(MTGCardInstance * card);
int isPaymentSet(); int isPaymentSet();
+7
View File
@@ -113,6 +113,13 @@ int ExtraCosts::doPay(){
} }
return result; return result;
} }
ExtraCosts::~ExtraCosts(){
for (size_t i = 0; i < costs.size(); i++){
SAFE_DELETE(costs[i]);
}
}
void ExtraCosts::Dump(){ void ExtraCosts::Dump(){
#ifdef WIN32 #ifdef WIN32
char buf[4096]; char buf[4096];
+1 -3
View File
@@ -12,9 +12,6 @@
#endif #endif
ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstance * c){ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstance * c){
#if defined (WIN32) || defined (LINUX)
char buf[4096];
#endif
ManaCost * manaCost; ManaCost * manaCost;
if (_manaCost){ if (_manaCost){
manaCost = _manaCost; manaCost = _manaCost;
@@ -159,6 +156,7 @@ void ManaCost::copy(ManaCost * _manaCost){
if (_manaCost->extraCosts){ if (_manaCost->extraCosts){
//TODO Deep copy ? //TODO Deep copy ?
if(!extraCostsIsCopy) SAFE_DELETE(extraCosts);
extraCosts = _manaCost->extraCosts; extraCosts = _manaCost->extraCosts;
extraCostsIsCopy = 1; extraCostsIsCopy = 1;
} }