VM: GC_BIGNUM must be called in the same scope as the variable declaration

db4
Björn Lindqvist 2014-09-17 19:46:05 +02:00 committed by Doug Coleman
parent cf6ae0ec2e
commit b90e52b527
2 changed files with 11 additions and 6 deletions

View File

@ -752,12 +752,12 @@ void factor_vm::bignum_divide_unsigned_large_denominator(
bignum *q = NULL; bignum *q = NULL;
if (quotient != ((bignum**)0)) { if (quotient != ((bignum**)0)) {
q = allot_bignum(length_n - length_d, q_negative_p); q = allot_bignum(length_n - length_d, q_negative_p);
GC_BIGNUM(q);
} else { } else {
q = BIGNUM_OUT_OF_BAND; q = BIGNUM_OUT_OF_BAND;
} }
GC_BIGNUM(q);
bignum* u = (allot_bignum(length_n, r_negative_p)); bignum* u = allot_bignum(length_n, r_negative_p);
GC_BIGNUM(u); GC_BIGNUM(u);
int shift = 0; int shift = 0;

View File

@ -35,14 +35,19 @@ struct gc_bignum {
factor_vm* parent; factor_vm* parent;
gc_bignum(bignum** addr, factor_vm* parent) : addr(addr), parent(parent) { gc_bignum(bignum** addr, factor_vm* parent) : addr(addr), parent(parent) {
/* Don't bother with variables holding NULL pointers. */
if (*addr) {
parent->check_data_pointer(*addr); parent->check_data_pointer(*addr);
parent->bignum_roots.push_back(addr); parent->bignum_roots.push_back(addr);
} }
}
~gc_bignum() { ~gc_bignum() {
if (*addr) {
FACTOR_ASSERT(parent->bignum_roots.back() == addr); FACTOR_ASSERT(parent->bignum_roots.back() == addr);
parent->bignum_roots.pop_back(); parent->bignum_roots.pop_back();
} }
}
}; };
#define GC_BIGNUM(x) gc_bignum x##__data_root(&x, this) #define GC_BIGNUM(x) gc_bignum x##__data_root(&x, this)