Commit a0a13341 authored by Bob Fang's avatar Bob Fang

fixing #167: using gc allocator for gmp

parent 381e2fcd
......@@ -385,7 +385,6 @@ Box* longRepr(BoxedLong* v) {
strcat(buf, "L");
auto rtn = new BoxedString(buf);
free(buf);
return rtn;
}
......@@ -397,7 +396,6 @@ Box* longStr(BoxedLong* v) {
char* buf = mpz_get_str(NULL, 10, v->n);
auto rtn = new BoxedString(buf);
free(buf);
return rtn;
}
......@@ -866,7 +864,21 @@ Box* longHash(BoxedLong* self) {
return boxInt(n);
}
void* customised_allocation(size_t alloc_size) {
return gc::gc_alloc(alloc_size, gc::GCKind::CONSERVATIVE);
}
void* customised_realloc(void* ptr, size_t old_size, size_t new_size) {
return gc::gc_realloc(ptr, new_size);
}
void customised_free(void* ptr, size_t size) {
gc::gc_free(ptr);
}
void setupLong() {
mp_set_memory_functions(customised_allocation, customised_realloc, customised_free);
long_cls->giveAttr("__name__", boxStrConstant("long"));
long_cls->giveAttr(
......
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