[Python-checkins] r46935 - sandbox/trunk/decimal-c/_decimal.c

mateusz.rukowicz python-checkins at python.org
Wed Jun 14 00:22:11 CEST 2006


Author: mateusz.rukowicz
Date: Wed Jun 14 00:22:03 2006
New Revision: 46935

Modified:
   sandbox/trunk/decimal-c/_decimal.c
Log:
Fixed one sigsegv and one refleak, there is no refleaks now.


Modified: sandbox/trunk/decimal-c/_decimal.c
==============================================================================
--- sandbox/trunk/decimal-c/_decimal.c	(original)
+++ sandbox/trunk/decimal-c/_decimal.c	Wed Jun 14 00:22:03 2006
@@ -1635,6 +1635,7 @@
     long i, minsize;
     decimalobject *longer, *ans;
     contextobject *ctx2;
+    PyObject *flags;
     
     if (ISSPECIAL(self) || ISSPECIAL(other)) {
         decimalobject *nan;
@@ -1676,13 +1677,15 @@
         }
 
         for (i = 0; i < minsize; i++) {
-            if (self->digits[i] != other->digits[i])
+            if (_limb_get_digit(self->limbs, self->ob_size, i) !=   /* SLOW */
+                _limb_get_digit(other->limbs, other->ob_size, i))
                 goto next;
         }
         /* Okay, now the remaining digits of the longer
            one must consist of only digits. */
         for (i = minsize; i < longer->ob_size; i++)
-            if (longer->digits[i] != 0)
+            /* SLOW */
+            if (_limb_get_digit(longer->limbs, longer->ob_size, i) != 0)
                 goto next;
         /* All digits match, so they're equal. */
         return 0;
@@ -1699,12 +1702,13 @@
     if (!ctx2) return 0; /* error */
 
     ctx2->rounding = ROUND_UP; /* away from 0 */
-    if (context_ignore_all_flags(ctx2) == NULL)
+    if ((flags = context_ignore_all_flags(ctx2)) == NULL)
         return 0; /* error */
 
-    Py_XDECREF(ctx2);
 
     ans = _do_decimal_subtract(self, other, ctx2);
+    Py_DECREF(ctx2);
+    Py_DECREF(flags);
     if (!ans) return 0;
 
     if (!decimal_nonzero(ans))
@@ -3421,7 +3425,8 @@
 
 static PyObject *
 decimal_power(PyObject *self, PyObject *other, PyObject *modulo) {
-/*    decimalobject *res;
+#if 0
+    decimalobject *res;
     contextobject *ctx = getcontext();
     if (!ctx) return NULL;
 
@@ -3443,8 +3448,10 @@
                             ctx);
     Py_DECREF(other);
     Py_DECREF(modulo);
-    return (PyObject *)res;*/
+    return (PyObject *)res;
+#else
     Py_RETURN_NONE;
+#endif
 }
 
 
@@ -4828,7 +4835,8 @@
 static PyObject *
 context_power(contextobject *self, PyObject *args)
 {               
-/*    PyObject *a, *b, *c;
+#if 0
+    PyObject *a, *b, *c;
     decimalobject *dec_a = NULL, *dec_b = NULL, *dec_c = NULL, *res;
     if (!PyArg_ParseTuple(args, "OO|O:power", &a, &b, &c))
         return NULL;          
@@ -4855,8 +4863,10 @@
     Py_DECREF(dec_a);
     Py_DECREF(dec_b);
     Py_DECREF(dec_c);
-    return (PyObject *)res;*/
+    return (PyObject *)res;
+#else
     Py_RETURN_NONE;
+#endif
 }
 
 


More information about the Python-checkins mailing list