mp.c: Simplify final cleanup in `MPCRT' operations.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 25 Nov 2019 13:25:34 +0000 (13:25 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 25 Nov 2019 17:51:33 +0000 (17:51 +0000)
mp.c

diff --git a/mp.c b/mp.c
index 6ce2792..456c905 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -1805,9 +1805,7 @@ static PyObject *mcmeth_solve(PyObject *me, PyObject *arg)
   z = mp_pywrap(mpcrt_solve(c, MP_NEW, v));
 end:
   if (v) {
-    n = i;
-    for (i = 0; i < n; i++)
-      MP_DROP(v[i]);
+    while (i--) MP_DROP(v[i]);
     xfree(v);
   }
   return (z);
@@ -1860,9 +1858,7 @@ static PyObject *mpcrt_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 
 end:
   if (v) {
-    n = i;
-    for (i = 0; i < n; i++)
-      MP_DROP(v[i].m);
+    while (i--) MP_DROP(v[i].m);
     xfree(v);
   }
   mp_drop(xx); mp_drop(y); mp_drop(g);