@@ -36,7 +36,15 @@ medium_value(PyLongObject *x)
3636#define IS_SMALL_INT (ival ) (-_PY_NSMALLNEGINTS <= (ival) && (ival) < _PY_NSMALLPOSINTS)
3737#define IS_SMALL_UINT (ival ) ((ival) < _PY_NSMALLPOSINTS)
3838
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 )
4048{
4149 /* Take care that we are comparing unsigned values. */
4250 twodigits x_plus_mask = ((twodigits )x ) + PyLong_MASK ;
@@ -58,7 +66,7 @@ maybe_small_long(PyLongObject *v)
5866 if (v && IS_MEDIUM_VALUE (v )) {
5967 stwodigits ival = medium_value (v );
6068 if (IS_SMALL_INT (ival )) {
61- Py_DECREF (v );
69+ _Py_DECREF_INT (v );
6270 return (PyLongObject * )get_small_int ((sdigit )ival );
6371 }
6472 }
@@ -1856,7 +1864,7 @@ long_to_decimal_string_internal(PyObject *aa,
18561864#undef WRITE_DIGITS
18571865#undef WRITE_UNICODE_DIGITS
18581866
1859- Py_DECREF (scratch );
1867+ _Py_DECREF_INT (scratch );
18601868 if (writer ) {
18611869 writer -> pos += strlen ;
18621870 }
@@ -3561,15 +3569,15 @@ k_mul(PyLongObject *a, PyLongObject *b)
35613569 */
35623570 i = Py_SIZE (ret ) - shift ; /* # digits after shift */
35633571 (void )v_isub (ret -> ob_digit + shift , i , t2 -> ob_digit , Py_SIZE (t2 ));
3564- Py_DECREF (t2 );
3572+ _Py_DECREF_INT (t2 );
35653573
35663574 (void )v_isub (ret -> ob_digit + shift , i , t1 -> ob_digit , Py_SIZE (t1 ));
3567- Py_DECREF (t1 );
3575+ _Py_DECREF_INT (t1 );
35683576
35693577 /* 6. t3 <- (ah+al)(bh+bl), and add into result. */
35703578 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 );
35733581 ah = al = NULL ;
35743582
35753583 if (a == b ) {
@@ -3580,21 +3588,21 @@ k_mul(PyLongObject *a, PyLongObject *b)
35803588 Py_DECREF (t1 );
35813589 goto fail ;
35823590 }
3583- Py_DECREF (bh );
3584- Py_DECREF (bl );
3591+ _Py_DECREF_INT (bh );
3592+ _Py_DECREF_INT (bl );
35853593 bh = bl = NULL ;
35863594
35873595 t3 = k_mul (t1 , t2 );
3588- Py_DECREF (t1 );
3589- Py_DECREF (t2 );
3596+ _Py_DECREF_INT (t1 );
3597+ _Py_DECREF_INT (t2 );
35903598 if (t3 == NULL ) goto fail ;
35913599 assert (Py_SIZE (t3 ) >= 0 );
35923600
35933601 /* Add t3. It's not obvious why we can't run out of room here.
35943602 * See the (*) comment after this function.
35953603 */
35963604 (void )v_iadd (ret -> ob_digit + shift , i , t3 -> ob_digit , Py_SIZE (t3 ));
3597- Py_DECREF (t3 );
3605+ _Py_DECREF_INT (t3 );
35983606
35993607 return long_normalize (ret );
36003608
@@ -3699,13 +3707,13 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
36993707 /* Add into result. */
37003708 (void )v_iadd (ret -> ob_digit + nbdone , Py_SIZE (ret ) - nbdone ,
37013709 product -> ob_digit , Py_SIZE (product ));
3702- Py_DECREF (product );
3710+ _Py_DECREF_INT (product );
37033711
37043712 bsize -= nbtouse ;
37053713 nbdone += nbtouse ;
37063714 }
37073715
3708- Py_DECREF (bslice );
3716+ _Py_DECREF_INT (bslice );
37093717 return long_normalize (ret );
37103718
37113719 fail :
@@ -5993,7 +6001,7 @@ PyTypeObject PyLong_Type = {
59936001 0 , /* tp_init */
59946002 0 , /* tp_alloc */
59956003 long_new , /* tp_new */
5996- PyObject_Del , /* tp_free */
6004+ PyObject_Free , /* tp_free */
59976005};
59986006
59996007static PyTypeObject Int_InfoType ;
0 commit comments