diff options
author | John Wiegley <johnw@newartisans.com> | 2006-03-13 23:42:21 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 05:48:44 -0400 |
commit | 3030e604f4abe3d2155eb77c124829f1d7213f35 (patch) | |
tree | 9955ae7945c22f1d5c990b64a5cfa9e57eb19f0c /amount.cc | |
parent | e13d0172554929858f4e0143583f0d50f413ef83 (diff) | |
download | fork-ledger-3030e604f4abe3d2155eb77c124829f1d7213f35.tar.gz fork-ledger-3030e604f4abe3d2155eb77c124829f1d7213f35.tar.bz2 fork-ledger-3030e604f4abe3d2155eb77c124829f1d7213f35.zip |
Don't cleanup commodities if Ledger was built in release mode.
Diffstat (limited to 'amount.cc')
-rw-r--r-- | amount.cc | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -9,6 +9,8 @@ namespace ledger { +bool do_cleanup = true; + #define BIGINT_BULK_ALLOC 0x0001 class amount_t::bigint_t { @@ -29,10 +31,7 @@ class amount_t::bigint_t { : prec(other.prec), flags(0), ref(1), index(0) { mpz_init_set(val, other.val); } - ~bigint_t() { - assert(ref == 0); - mpz_clear(val); - } + ~bigint_t(); }; unsigned int sizeof_bigint_t() { @@ -41,10 +40,16 @@ unsigned int sizeof_bigint_t() { #define MPZ(x) ((x)->val) -static mpz_t temp; -static mpz_t divisor; +static mpz_t temp; +static mpz_t divisor; + static amount_t::bigint_t true_value; +inline amount_t::bigint_t::~bigint_t() { + assert(ref == 0 || (! do_cleanup && this == &true_value)); + mpz_clear(val); +} + commodity_t::updater_t * commodity_t::updater = NULL; commodities_map commodity_t::commodities; commodity_t * commodity_t::null_commodity; @@ -83,6 +88,9 @@ static struct _init_amounts { } ~_init_amounts() { + if (! do_cleanup) + return; + mpz_clear(temp); mpz_clear(divisor); |