bignums: prevent bignum registers from growing too big

We had this code before, but it made non-functional in commit
20f4c8931e and got removed with commit
749b97d06c.
This commit is contained in:
Marius Gerbershagen 2020-01-04 18:03:47 +01:00
parent c301b108a7
commit c2a577d609
2 changed files with 5 additions and 1 deletions

View file

@ -46,7 +46,10 @@
void
_ecl_big_register_free(cl_object x)
{
return;
/* We only need to free the integer when it gets too large */
if (ECL_BIGNUM_DIM(x) > 4 * ECL_BIG_REGISTER_SIZE) {
_ecl_big_realloc2(x, ECL_BIG_REGISTER_SIZE);
}
}
static cl_object

View file

@ -45,6 +45,7 @@ extern ECL_API _ecl_big_binary_op _ecl_big_boole_operator(int op);
#define _ecl_big_set_index(x, f) mpz_set_ui((x)->big.big_num,(f))
#endif
#define _ecl_big_init2(x,size) mpz_init2((x)->big.big_num,(size)*GMP_LIMB_BITS)
#define _ecl_big_realloc2(x,size) mpz_realloc2((x)->big.big_num,(size)*GMP_LIMB_BITS)
#define _ecl_big_clear(x) mpz_clear((x)->big.big_num)
#define _ecl_big_set(x,y) mpz_set((x)->big.big_num,(y)->big.big_num)
#define _ecl_big_odd_p(x) ((mpz_get_ui(x->big.big_num) & 1) != 0)