Commit bd48b859 authored by Daniel Kochmański's avatar Daniel Kochmański
Browse files

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: default avatarDaniel Kochmański <dkochmanski@turtle-solutions.eu>
parent 26690cac
......@@ -282,24 +282,24 @@ _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));
return ecl_alloc_uncollectable(size);
}
static void
mp_free(void *ptr, size_t size)
{
ecl_free_uncollectable(ptr);
}
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));
mp_limb_t *p = mp_alloc(nsize);
memcpy(p, ptr, (osize < nsize)? osize : nsize);
ecl_dealloc(ptr);
mp_free(ptr, osize);
return p;
}
static void
mp_free(void *ptr, size_t size)
{
ecl_dealloc(ptr);
}
cl_fixnum
fixint(cl_object x)
{
......
......@@ -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;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment