summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-15 17:08:56 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-15 17:08:56 -0400
commit7189b181ef3e0da74d992da87771fa26399391bc (patch)
tree3c6b677a54161fb63cb169c93d9eade0b316b4da /amount.cc
parent78c44b5e795a98baacfbc56943b784370956cbca (diff)
downloadfork-ledger-7189b181ef3e0da74d992da87771fa26399391bc.tar.gz
fork-ledger-7189b181ef3e0da74d992da87771fa26399391bc.tar.bz2
fork-ledger-7189b181ef3e0da74d992da87771fa26399391bc.zip
further restructuring
Diffstat (limited to 'amount.cc')
-rw-r--r--amount.cc23
1 files changed, 10 insertions, 13 deletions
diff --git a/amount.cc b/amount.cc
index b8b5451a..8499348c 100644
--- a/amount.cc
+++ b/amount.cc
@@ -776,27 +776,24 @@ void amount_t::read_quantity(std::istream& in)
}
}
-void (*commodity_t::updater)(commodity_t * commodity,
- const std::time_t date,
- const amount_t& price,
- const std::time_t moment) = NULL;
+commodity_t::updater_t * commodity_t::updater = NULL;
+commodities_map commodity_t::commodities;
+commodity_t * commodity_t::null_commodity =
+ commodity_t::find_commodity("", true);
-commodities_map commodity_t::commodities;
-commodity_t * commodity_t::null_commodity =
- commodity_t::find_commodity("", true);
-
-struct cleanup_commodities
+static struct cleanup_commodities
{
~cleanup_commodities() {
+ if (commodity_t::updater)
+ delete commodity_t::updater;
+
for (commodities_map::iterator i
= commodity_t::commodities.begin();
i != commodity_t::commodities.end();
i++)
delete (*i).second;
}
-};
-
-static cleanup_commodities cleanup;
+} _cleanup;
commodity_t * commodity_t::find_commodity(const std::string& symbol,
bool auto_create)
@@ -820,7 +817,7 @@ amount_t commodity_t::value(const std::time_t moment)
amount_t price;
if (updater)
- updater(this, age, price, moment);
+ (*updater)(this, age, price, moment);
for (history_map::reverse_iterator i = history.rbegin();
i != history.rend();