[Numpy-svn] r5394 - trunk/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sat Jul 12 01:26:42 CDT 2008


Author: charris
Date: 2008-07-12 01:26:40 -0500 (Sat, 12 Jul 2008)
New Revision: 5394

Modified:
   trunk/numpy/core/src/scalartypes.inc.src
Log:
Make buffers local for reentrancy.

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2008-07-12 05:17:43 UTC (rev 5393)
+++ trunk/numpy/core/src/scalartypes.inc.src	2008-07-12 06:26:40 UTC (rev 5394)
@@ -553,7 +553,9 @@
 /**begin repeat
  * #name=float, double, longdouble#
  * #NAME=FLOAT, DOUBLE, LONGDOUBLE#
- * #PREFIX=NPY_,NPY_,NPY_#
+ * #PREFIX=NPY_, NPY_, NPY_#
+ *
+ * Fixme: buflen isn't checked when appending .0
  */
 static void
 format_@name@(char *buf, size_t buflen, @name@ val,
@@ -625,6 +627,8 @@
 
 /*
  * float type str and repr
+ *
+ * These functions will return NULL if PyString creation fails.
  */
 /**begin repeat
  * #name=float, double, longdouble#
@@ -638,23 +642,23 @@
 static PyObject *
 @name@type_@kind@(PyObject *self)
 {
-    static char buf[100];
-    @name@ x = ((Py@Name@ScalarObject *)self)->obval;
+    char buf[100];
+    @name@ val = ((Py@Name@ScalarObject *)self)->obval;
 
-    format_@name@(buf, sizeof(buf), x, @NAME@PREC_@KIND@);
+    format_@name@(buf, sizeof(buf), val, @NAME@PREC_@KIND@);
     return PyString_FromString(buf);
 }
 
 static PyObject *
 c@name@type_@kind@(PyObject *self)
 {
-    static char buf1[100];
-    static char buf2[100];
-    static char buf3[202];
-    c@name@ x = ((PyC@Name@ScalarObject *)self)->obval;
+    char buf1[100];
+    char buf2[100];
+    char buf3[202];
+    c@name@ val = ((PyC@Name@ScalarObject *)self)->obval;
 
-    format_@name@(buf1, sizeof(buf1), x.real, @NAME@PREC_@KIND@);
-    format_@name@(buf2, sizeof(buf2), x.imag, @NAME@PREC_@KIND@);
+    format_@name@(buf1, sizeof(buf1), val.real, @NAME@PREC_@KIND@);
+    format_@name@(buf2, sizeof(buf2), val.imag, @NAME@PREC_@KIND@);
     snprintf(buf3, sizeof(buf3), "(%s+%sj)", buf1, buf2);
     return PyString_FromString(buf3);
 }



More information about the Numpy-svn mailing list