bignums: don't collect gmp internal memory
GMP manual at https://gmplib.org/manual/Custom-Allocation.html sates, taht "GMP may use allocated blocks to hold pointers to other allocated blocks. This will limit the assumptions a conservative garbage collection scheme can make.", therefore we won't collect it's internal blocks. Fixes #58. Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
This commit is contained in:
parent
26690cacdd
commit
bd48b85970
2 changed files with 12 additions and 11 deletions
22
src/c/big.d
22
src/c/big.d
|
|
@ -282,22 +282,22 @@ _ecl_fix_divided_by_big(cl_fixnum x, cl_object y)
|
|||
static void *
|
||||
mp_alloc(size_t size)
|
||||
{
|
||||
return ecl_alloc_atomic_align(size, sizeof(mp_limb_t));
|
||||
}
|
||||
|
||||
static void *
|
||||
mp_realloc(void *ptr, size_t osize, size_t nsize)
|
||||
{
|
||||
mp_limb_t *p = ecl_alloc_atomic_align(nsize, sizeof(mp_limb_t));
|
||||
memcpy(p, ptr, (osize < nsize)? osize : nsize);
|
||||
ecl_dealloc(ptr);
|
||||
return p;
|
||||
return ecl_alloc_uncollectable(size);
|
||||
}
|
||||
|
||||
static void
|
||||
mp_free(void *ptr, size_t size)
|
||||
{
|
||||
ecl_dealloc(ptr);
|
||||
ecl_free_uncollectable(ptr);
|
||||
}
|
||||
|
||||
static void *
|
||||
mp_realloc(void *ptr, size_t osize, size_t nsize)
|
||||
{
|
||||
mp_limb_t *p = mp_alloc(nsize);
|
||||
memcpy(p, ptr, (osize < nsize)? osize : nsize);
|
||||
mp_free(ptr, osize);
|
||||
return p;
|
||||
}
|
||||
|
||||
cl_fixnum
|
||||
|
|
|
|||
|
|
@ -234,6 +234,7 @@ ecl_to_uint64_t(cl_object x) {
|
|||
output = (ecl_uint64_t)mpz_get_ui(copy->big.big_num);
|
||||
output = (output << 32) +
|
||||
(ecl_uint64_t)mpz_get_ui(x->big.big_num);
|
||||
_ecl_big_register_free(copy);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue