summaryrefslogtreecommitdiff
path: root/walk.cc
diff options
context:
space:
mode:
Diffstat (limited to 'walk.cc')
-rw-r--r--walk.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/walk.cc b/walk.cc
index 9f7ee8b1..c6ea3254 100644
--- a/walk.cc
+++ b/walk.cc
@@ -45,12 +45,13 @@ void add_transaction_to(const transaction_t& xact, value_t& value)
value += transaction_xdata_(xact).composite_amount;
}
else if (xact.cost || xact.amount.commodity().price || value) {
- std::auto_ptr<amount_t> price;
- amount_t * cost = xact.cost;
- if (xact.amount.commodity().price)
- price.reset(new amount_t(*xact.amount.commodity().price *
- xact.amount));
- value.add(base_amount(xact.amount), price.get(), cost);
+ if (xact.amount.commodity().price) {
+ amount_t price(*xact.amount.commodity().price);
+ price *= xact.amount;
+ value.add(base_amount(xact.amount), &price, xact.cost);
+ } else {
+ value.add(base_amount(xact.amount), NULL, xact.cost);
+ }
}
else {
value = xact.amount;