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

mateusz.rukowicz python-checkins at python.org
Tue May 30 20:35:15 CEST 2006


Author: mateusz.rukowicz
Date: Tue May 30 20:35:14 2006
New Revision: 46565
Modified:
 sandbox/trunk/decimal-c/_decimal.c
Log:
Some memleaks fix.
Modified: sandbox/trunk/decimal-c/_decimal.c
==============================================================================
--- sandbox/trunk/decimal-c/_decimal.c	(original)
+++ sandbox/trunk/decimal-c/_decimal.c	Tue May 30 20:35:14 2006
@@ -1963,7 +1963,7 @@
 if (!decimal_nonzero(self)) {
 oexp = other->exp - ctx->prec - 1;
 exp = (exp > oexp ? exp : oexp);
- res = _decimal_rescale(other, exp, ctx, 0);
+ res = _decimal_rescale(other, exp, ctx, 0, 1);
 if (!res) return NULL;
 if (shouldround) {
 res2 = _decimal_fix(res, ctx);
@@ -1976,7 +1976,7 @@
 if (!decimal_nonzero(other)) {
 oexp = self->exp - ctx->prec - 1;
 exp = (exp > oexp ? exp : oexp);
- res = _decimal_rescale(self, exp, ctx, 0);
+ res = _decimal_rescale(self, exp, ctx, 0, 1);
 if (!res) return NULL;
 if (shouldround) {
 res2 = _decimal_fix(res, ctx);
@@ -2646,18 +2646,18 @@
 } else {
 tup = PySequence_Tuple(seq);
 if (!tup)
- return NULL;
+ goto err;
 }
 
 if (PyTuple_GET_SIZE(tup) != 3) {
 PyErr_SetString(PyExc_ValueError, "Invalid arguments");
- return NULL;
+ goto err;
 }
 if (!PyArg_ParseTuple(tup, "iOl", &sign, &digits, &exp))
- return NULL;
+ goto err;
 if (sign < 0 || sign > 7) {
 PyErr_SetString(PyExc_ValueError, "Invalid sign");
- return NULL;
+ goto err;
 }
 digtup = PySequence_Tuple(digits);
 if (!digtup) {
@@ -2671,22 +2671,22 @@
 long x = PyInt_AsLong(item);
 if (x < 0 || x > 9) {
 PyErr_Format(PyExc_ValueError, "Invalid digit: %ld", x);
- return NULL;
+ goto err;
 }
 new->digits[i] = (signed char)x;
 } else if (PyLong_Check(item)) {
 long x = PyLong_AsLong(item);
 if (x == -1 && PyErr_Occurred())
- return NULL;
+ goto err;
 if (x < 0 || x > 9) {
 PyErr_Format(PyExc_ValueError, "Invalid digit: %ld", x);
- return NULL;
+ return err;
 }
 new->digits[i] = (signed char)x;
 } else {
 PyErr_SetString(PyExc_ValueError, "The second value in the tuple "
 "must be composed of non negative integer elements.");
- return NULL;
+ return err;
 }
 }
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /