Don't cleanup commodities if Ledger was built in release mode.
This commit is contained in:
parent
e13d017255
commit
3030e604f4
3 changed files with 19 additions and 6 deletions
16
amount.cc
16
amount.cc
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
|
bool do_cleanup = true;
|
||||||
|
|
||||||
#define BIGINT_BULK_ALLOC 0x0001
|
#define BIGINT_BULK_ALLOC 0x0001
|
||||||
|
|
||||||
class amount_t::bigint_t {
|
class amount_t::bigint_t {
|
||||||
|
|
@ -29,10 +31,7 @@ class amount_t::bigint_t {
|
||||||
: prec(other.prec), flags(0), ref(1), index(0) {
|
: prec(other.prec), flags(0), ref(1), index(0) {
|
||||||
mpz_init_set(val, other.val);
|
mpz_init_set(val, other.val);
|
||||||
}
|
}
|
||||||
~bigint_t() {
|
~bigint_t();
|
||||||
assert(ref == 0);
|
|
||||||
mpz_clear(val);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int sizeof_bigint_t() {
|
unsigned int sizeof_bigint_t() {
|
||||||
|
|
@ -43,8 +42,14 @@ unsigned int sizeof_bigint_t() {
|
||||||
|
|
||||||
static mpz_t temp;
|
static mpz_t temp;
|
||||||
static mpz_t divisor;
|
static mpz_t divisor;
|
||||||
|
|
||||||
static amount_t::bigint_t true_value;
|
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;
|
commodity_t::updater_t * commodity_t::updater = NULL;
|
||||||
commodities_map commodity_t::commodities;
|
commodities_map commodity_t::commodities;
|
||||||
commodity_t * commodity_t::null_commodity;
|
commodity_t * commodity_t::null_commodity;
|
||||||
|
|
@ -83,6 +88,9 @@ static struct _init_amounts {
|
||||||
}
|
}
|
||||||
|
|
||||||
~_init_amounts() {
|
~_init_amounts() {
|
||||||
|
if (! do_cleanup)
|
||||||
|
return;
|
||||||
|
|
||||||
mpz_clear(temp);
|
mpz_clear(temp);
|
||||||
mpz_clear(divisor);
|
mpz_clear(divisor);
|
||||||
|
|
||||||
|
|
|
||||||
2
amount.h
2
amount.h
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
|
extern bool do_cleanup;
|
||||||
|
|
||||||
class commodity_t;
|
class commodity_t;
|
||||||
|
|
||||||
class amount_t
|
class amount_t
|
||||||
|
|
|
||||||
3
main.cc
3
main.cc
|
|
@ -350,6 +350,9 @@ int parse_and_report(int argc, char * argv[], char * envp[])
|
||||||
int main(int argc, char * argv[], char * envp[])
|
int main(int argc, char * argv[], char * envp[])
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
#if DEBUG_LEVEL < BETA
|
||||||
|
ledger::do_cleanup = false;
|
||||||
|
#endif
|
||||||
return parse_and_report(argc, argv, envp);
|
return parse_and_report(argc, argv, envp);
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception& err) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue