@@ -36,7 +36,15 @@ medium_value(PyLongObject *x)
36
36
#define IS_SMALL_INT (ival ) (-_PY_NSMALLNEGINTS <= (ival) && (ival) < _PY_NSMALLPOSINTS)
37
37
#define IS_SMALL_UINT (ival ) ((ival) < _PY_NSMALLPOSINTS)
38
38
39
- static inline int is_medium_int (stwodigits x )
39
+ static inline void
40
+ _Py_DECREF_INT (PyLongObject * op )
41
+ {
42
+ assert (PyLong_CheckExact (op ));
43
+ _Py_DECREF_SPECIALIZED ((PyObject * )op , PyObject_Free );
44
+ }
45
+
46
+ static inline int
47
+ is_medium_int (stwodigits x )
40
48
{
41
49
/* Take care that we are comparing unsigned values. */
42
50
twodigits x_plus_mask = ((twodigits )x ) + PyLong_MASK ;
@@ -58,7 +66,7 @@ maybe_small_long(PyLongObject *v)
58
66
if (v && IS_MEDIUM_VALUE (v )) {
59
67
stwodigits ival = medium_value (v );
60
68
if (IS_SMALL_INT (ival )) {
61
- Py_DECREF (v );
69
+ _Py_DECREF_INT (v );
62
70
return (PyLongObject * )get_small_int ((sdigit )ival );
63
71
}
64
72
}
@@ -1856,7 +1864,7 @@ long_to_decimal_string_internal(PyObject *aa,
1856
1864
#undef WRITE_DIGITS
1857
1865
#undef WRITE_UNICODE_DIGITS
1858
1866
1859
- Py_DECREF (scratch );
1867
+ _Py_DECREF_INT (scratch );
1860
1868
if (writer ) {
1861
1869
writer -> pos += strlen ;
1862
1870
}
@@ -3561,15 +3569,15 @@ k_mul(PyLongObject *a, PyLongObject *b)
3561
3569
*/
3562
3570
i = Py_SIZE (ret ) - shift ; /* # digits after shift */
3563
3571
(void )v_isub (ret -> ob_digit + shift , i , t2 -> ob_digit , Py_SIZE (t2 ));
3564
- Py_DECREF (t2 );
3572
+ _Py_DECREF_INT (t2 );
3565
3573
3566
3574
(void )v_isub (ret -> ob_digit + shift , i , t1 -> ob_digit , Py_SIZE (t1 ));
3567
- Py_DECREF (t1 );
3575
+ _Py_DECREF_INT (t1 );
3568
3576
3569
3577
/* 6. t3 <- (ah+al)(bh+bl), and add into result. */
3570
3578
if ((t1 = x_add (ah , al )) == NULL ) goto fail ;
3571
- Py_DECREF (ah );
3572
- Py_DECREF (al );
3579
+ _Py_DECREF_INT (ah );
3580
+ _Py_DECREF_INT (al );
3573
3581
ah = al = NULL ;
3574
3582
3575
3583
if (a == b ) {
@@ -3580,21 +3588,21 @@ k_mul(PyLongObject *a, PyLongObject *b)
3580
3588
Py_DECREF (t1 );
3581
3589
goto fail ;
3582
3590
}
3583
- Py_DECREF (bh );
3584
- Py_DECREF (bl );
3591
+ _Py_DECREF_INT (bh );
3592
+ _Py_DECREF_INT (bl );
3585
3593
bh = bl = NULL ;
3586
3594
3587
3595
t3 = k_mul (t1 , t2 );
3588
- Py_DECREF (t1 );
3589
- Py_DECREF (t2 );
3596
+ _Py_DECREF_INT (t1 );
3597
+ _Py_DECREF_INT (t2 );
3590
3598
if (t3 == NULL ) goto fail ;
3591
3599
assert (Py_SIZE (t3 ) >= 0 );
3592
3600
3593
3601
/* Add t3. It's not obvious why we can't run out of room here.
3594
3602
* See the (*) comment after this function.
3595
3603
*/
3596
3604
(void )v_iadd (ret -> ob_digit + shift , i , t3 -> ob_digit , Py_SIZE (t3 ));
3597
- Py_DECREF (t3 );
3605
+ _Py_DECREF_INT (t3 );
3598
3606
3599
3607
return long_normalize (ret );
3600
3608
@@ -3699,13 +3707,13 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
3699
3707
/* Add into result. */
3700
3708
(void )v_iadd (ret -> ob_digit + nbdone , Py_SIZE (ret ) - nbdone ,
3701
3709
product -> ob_digit , Py_SIZE (product ));
3702
- Py_DECREF (product );
3710
+ _Py_DECREF_INT (product );
3703
3711
3704
3712
bsize -= nbtouse ;
3705
3713
nbdone += nbtouse ;
3706
3714
}
3707
3715
3708
- Py_DECREF (bslice );
3716
+ _Py_DECREF_INT (bslice );
3709
3717
return long_normalize (ret );
3710
3718
3711
3719
fail :
@@ -5993,7 +6001,7 @@ PyTypeObject PyLong_Type = {
5993
6001
0 , /* tp_init */
5994
6002
0 , /* tp_alloc */
5995
6003
long_new , /* tp_new */
5996
- PyObject_Del , /* tp_free */
6004
+ PyObject_Free , /* tp_free */
5997
6005
};
5998
6006
5999
6007
static PyTypeObject Int_InfoType ;
0 commit comments