[Zope-Checkins] CVS: ZODB3/ZODB - TimeStamp.c:1.17.44.1

Tim Peters tim.one@comcast.net
Thu, 19 Jun 2003 18:11:19 -0400


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv20934/ZODB

Modified Files:
      Tag: ZODB3-3_2-branch
	TimeStamp.c 
Log Message:
TimeStamp_laterThan():  This leaked a Python string object whenever it
had to create a new timestamp.  Fixed.

check2ZODBThreads(), check7ZODBThreads():  Close the database when
these tests end.  Else they leak bigtime, obscuring searches for real
leaks.


=== ZODB3/ZODB/TimeStamp.c 1.17 => 1.17.44.1 ===
--- ZODB3/ZODB/TimeStamp.c:1.17	Wed Nov 13 11:32:03 2002
+++ ZODB3/ZODB/TimeStamp.c	Thu Jun 19 18:10:48 2003
@@ -222,7 +222,7 @@
 TimeStamp_laterThan(TimeStamp *self, PyObject *args)
 {
   TimeStamp *o=NULL;
-  unsigned char *s;
+  unsigned char s[8];
   PyObject *a;
   int i;
   
@@ -236,9 +236,7 @@
 
   self=o;
 
-  UNLESS(a=PyString_FromStringAndSize((char *) self->data, 8)) return NULL;
-  s=(unsigned char *)PyString_AsString(a);
-  
+  memcpy(s, self->data, 8);
   for (i=7; i > 3; i--) 
     {
       if (s[i] == 255) 
@@ -246,7 +244,8 @@
       else
 	{
 	  s[i]++;
-	  return PyObject_CallFunction(OBJECT(self->ob_type), "O", a);
+	  return PyObject_CallFunction(OBJECT(self->ob_type), "N", 
+	             PyString_FromStringAndSize(s, 8));
 	}
     }