moved some debug code around
This commit is contained in:
parent
b030416982
commit
6392b01799
2 changed files with 20 additions and 17 deletions
35
amount.cc
35
amount.cc
|
|
@ -10,11 +10,24 @@
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
static int ctors = 0;
|
int bigint_ctors = 0;
|
||||||
static int dtors = 0;
|
int bigint_dtors = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct amount_t::bigint_t {
|
#ifdef DEBUG_ENABLED
|
||||||
|
static struct ctor_dtor_info {
|
||||||
|
~ctor_dtor_info() {
|
||||||
|
DEBUG_CLASS("ledger.amount.bigint");
|
||||||
|
DEBUG_PRINT_("bigint_t ctor count = " << bigint_ctors);
|
||||||
|
DEBUG_PRINT_("bigint_t dtor count = " << bigint_dtors);
|
||||||
|
}
|
||||||
|
} __info;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class amount_t::bigint_t {
|
||||||
|
bigint_t(const bigint_t&);
|
||||||
|
|
||||||
|
public:
|
||||||
mpz_t val;
|
mpz_t val;
|
||||||
unsigned int ref;
|
unsigned int ref;
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
|
|
@ -22,34 +35,24 @@ struct amount_t::bigint_t {
|
||||||
bigint_t() : ref(1), index(0) {
|
bigint_t() : ref(1), index(0) {
|
||||||
mpz_init(val);
|
mpz_init(val);
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
ctors++;
|
bigint_ctors++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
bigint_t(mpz_t _val) : ref(1), index(0) {
|
bigint_t(mpz_t _val) : ref(1), index(0) {
|
||||||
mpz_init_set(val, _val);
|
mpz_init_set(val, _val);
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
ctors++;
|
bigint_ctors++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
~bigint_t() {
|
~bigint_t() {
|
||||||
assert(ref == 0);
|
assert(ref == 0);
|
||||||
mpz_clear(val);
|
mpz_clear(val);
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
dtors++;
|
bigint_dtors++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
static struct ctor_dtor_info {
|
|
||||||
~ctor_dtor_info() {
|
|
||||||
DEBUG_CLASS("ledger.amount.bigint");
|
|
||||||
DEBUG_PRINT_("bigint_t ctor count = " << ctors);
|
|
||||||
DEBUG_PRINT_("bigint_t dtor count = " << dtors);
|
|
||||||
}
|
|
||||||
} __info;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MPZ(x) ((x)->val)
|
#define MPZ(x) ((x)->val)
|
||||||
|
|
||||||
static mpz_t temp;
|
static mpz_t temp;
|
||||||
|
|
|
||||||
2
amount.h
2
amount.h
|
|
@ -28,7 +28,7 @@ class amount_t
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct bigint_t;
|
class bigint_t;
|
||||||
|
|
||||||
bigint_t * quantity; // amount, to MAX_PRECISION
|
bigint_t * quantity; // amount, to MAX_PRECISION
|
||||||
unsigned short precision;
|
unsigned short precision;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue