Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/runtime/long.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ int _PyLong_DigitValue[256] = {
#define IS_LITTLE_ENDIAN (int)*(unsigned char*)&one
#define PY_ABS_LLONG_MIN (0 - (unsigned PY_LONG_LONG)PY_LLONG_MIN)

void BoxedLong::tp_dealloc(Box* b) noexcept {
mpz_clear(static_cast<BoxedLong*>(b)->n);
}

extern "C" int _PyLong_Sign(PyObject* l) noexcept {
return mpz_sgn(static_cast<BoxedLong*>(l)->n);
}
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/long.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class BoxedLong : public Box {

BoxedLong() __attribute__((visibility("default"))) {}

static void tp_dealloc(Box* b) noexcept;

DEFAULT_CLASS_SIMPLE(long_cls, false);
};

Expand Down
3 changes: 2 additions & 1 deletion src/runtime/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4227,7 +4227,8 @@ void setupRuntime() {
int_cls->tp_flags |= Py_TPFLAGS_INT_SUBCLASS;
bool_cls = new (0) BoxedClass(int_cls, 0, 0, sizeof(BoxedBool), false, "bool", false, NULL, NULL, false);
complex_cls = new (0) BoxedClass(object_cls, 0, 0, sizeof(BoxedComplex), false, "complex", true, NULL, NULL, false);
long_cls = new (0) BoxedClass(object_cls, 0, 0, sizeof(BoxedLong), false, "long", true, NULL, NULL, false);
long_cls = new (0)
BoxedClass(object_cls, 0, 0, sizeof(BoxedLong), false, "long", true, BoxedLong::tp_dealloc, NULL, false);
long_cls->tp_flags |= Py_TPFLAGS_LONG_SUBCLASS;
float_cls = new (0)
BoxedClass(object_cls, 0, 0, sizeof(BoxedFloat), false, "float", true, BoxedFloat::tp_dealloc, NULL, false);
Expand Down