[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src theme.cpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src theme.cpp |
Date: |
Tue, 02 Aug 2005 19:35:30 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 05/08/02 23:35:30
Modified files:
src : theme.cpp
Log message:
fixed memory leaks
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/theme.cpp.diff?tr1=1.41&tr2=1.42&r1=text&r2=text
Patches:
Index: wesnoth/src/theme.cpp
diff -u wesnoth/src/theme.cpp:1.41 wesnoth/src/theme.cpp:1.42
--- wesnoth/src/theme.cpp:1.41 Wed Jul 20 08:22:37 2005
+++ wesnoth/src/theme.cpp Tue Aug 2 23:35:29 2005
@@ -1,4 +1,4 @@
-/* $Id: theme.cpp,v 1.41 2005/07/20 08:22:37 ott Exp $ */
+/* $Id: theme.cpp,v 1.42 2005/08/02 23:35:29 Sirp Exp $ */
/*
Copyright (C) 2003-5 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -144,9 +144,8 @@
}
#endif
- config* expand_partialresolution(const config& cfg, const config&
topcfg) {
+ void expand_partialresolution(const config& cfg, const config& topcfg,
config& outcfg) {
// start with a copy of the declared parent
- config* outcfg;
const config* origcfg = topcfg.find_child("resolution", "id",
cfg["inherits"]);
if (origcfg == NULL) {
origcfg = topcfg.find_child("partialresolution", "id",
cfg["inherits"]);
@@ -157,30 +156,30 @@
// expand parent again - not so big a deal, the only
thing really
// done again is applying he parent's changes, since we
would have
// copied anyway.
- outcfg = expand_partialresolution(*origcfg, topcfg);
+ expand_partialresolution(*origcfg, topcfg, outcfg);
} else {
- outcfg = new config(*origcfg);
+ outcfg = *origcfg;
}
// FIXME: we should ignore any id attribute from inherited
[resolution]
// override attributes
for(string_map::const_iterator j = cfg.values.begin(); j !=
cfg.values.end(); ++j) {
- outcfg->values[j->first] = j->second;
+ outcfg.values[j->first] = j->second;
}
// apply operations
{
const config::child_list& c =
cfg.get_children("remove");
for(config::child_list::const_iterator i = c.begin(); i
!= c.end(); ++i) {
- find_ref ((**i)["id"], *outcfg,
+ find_ref ((**i)["id"], outcfg,
true /* remove found child */);
}
}
{
const config::child_list& c =
cfg.get_children("change");
for(config::child_list::const_iterator i = c.begin(); i
!= c.end(); ++i) {
- config& target = find_ref ((**i)["id"],
*outcfg);
+ config& target = find_ref ((**i)["id"], outcfg);
for(string_map::iterator j =
(**i).values.begin();
j != (**i).values.end(); ++j) {
target.values[j->first] = j->second;
@@ -195,13 +194,11 @@
for(config::child_map::const_iterator j =
m.begin(); j != m.end(); ++j) {
for(config::child_list::const_iterator
i = j->second.begin();
i != j->second.end(); ++i) {
- outcfg->add_child(j->first,
**i);
+ outcfg.add_child(j->first, **i);
}
}
}
}
-
- return outcfg;
}
void do_resolve_rects(const config& cfg, config& resolved_config,
@@ -210,17 +207,17 @@
// recursively resolve children
for(config::all_children_iterator i = cfg.ordered_begin(); i !=
cfg.ordered_end(); ++i) {
const std::pair<const std::string*,const config*>&
value = *i;
- const std::string* childname = value.first;
- const config* sourceconfig = value.second;
+ std::string childname = *value.first;
+ const config* sourceconfig = value.second;
+ config partialcfg;
if (*value.first == "partialresolution") {
- childname = new std::string("resolution");
- sourceconfig = expand_partialresolution
(*sourceconfig, topcfg);
+ childname = "resolution";
+ expand_partialresolution (*sourceconfig,
topcfg, partialcfg);
+ sourceconfig = &partialcfg;
}
- config& childcfg =
resolved_config.add_child(*childname);
+ config& childcfg = resolved_config.add_child(childname);
do_resolve_rects(*sourceconfig, childcfg, topcfg,
- (*childname=="resolution") ? &childcfg
: resol_cfg);
-
- if (childname != value.first) delete childname;
+ (childname=="resolution") ? &childcfg
: resol_cfg);
}
// copy all key/values
@@ -252,13 +249,13 @@
}
}
- config& resolve_rects(const config& cfg) {
- config* newcfg = new config();
+ config resolve_rects(const config& cfg) {
+ config newcfg;
- do_resolve_rects(cfg, *newcfg, cfg);
+ do_resolve_rects(cfg, newcfg, cfg);
//std::cerr << newcfg->write();
- return *newcfg;
+ return newcfg;
}
}
- [Wesnoth-cvs-commits] wesnoth/src theme.cpp,
David White <=