[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#151489: python-apt: fixed the big leak, but there is something left.



On Mon, Jul 01, 2002 at 03:43:42PM -0600, Jason Gunthorpe wrote:
> 
> On Mon, 1 Jul 2002, Manuel Estrada Sainz wrote:
> 
> >  I attach a patch to python-apt which fixes the big leak by keeping
> >  track of and deleting the PkgCacheFile objects.
> 
> Yes, this particular leak is why the GetCache method is called
> TmpGetCache.. It wasn't ment to be a completely correct solution..
> 
> Your patch isn't entirely great.. The pkgcache py-wrapper should not be
> changed. It was ment to be as it is. The problem is that TmpGetCache
> doesn't create a PkgCacheFile pyobject to hold the reference to that
> class. It should do that and attach it to via the Owned mechanism to the
> PkgCache object it returns.
 
 Thanks for the guidance, hopefully I got it right this time.

> Ah, yes, the soruce list is leaking. tsk. Attached patch will fix that.

 That fixed it, thanks, when will the patch reach the oficial debian
 packages?

 Thanks

 	ranty

-- 
--- Manuel Estrada Sainz <ranty@debian.org>
                         <ranty@bigfoot.com>
			 <ranty@users.sourceforge.net>
------------------------ <manuel.estrada@hispalinux.es> -------------------
God grant us the serenity to accept the things we cannot change, courage to
change the things we can, and wisdom to know the difference.
diff -urN python-apt-0.5.4.3/python/cache.cc python-apt-0.5.4.3-mine/python/cache.cc
--- python-apt-0.5.4.3/python/cache.cc	Tue Feb 26 02:36:15 2002
+++ python-apt-0.5.4.3-mine/python/cache.cc	Fri Jul  5 04:02:49 2002
@@ -143,6 +143,26 @@
    0,                                   // tp_hash
 };
 
+PyTypeObject PkgCacheFileType =
+{
+   PyObject_HEAD_INIT(&PyType_Type)
+   0,			                // ob_size
+   "pkgCacheFile",                      // tp_name
+   sizeof(CppOwnedPyObject<pkgCacheFile>),   // tp_basicsize
+   0,                                   // tp_itemsize
+   // Methods
+   CppOwnedDealloc<pkgCacheFile>,       // tp_dealloc
+   0,                                   // tp_print
+   0,                                   // tp_getattr
+   0,                                   // tp_setattr
+   0,                                   // tp_compare
+   0,                                   // tp_repr
+   0,                                   // tp_as_number
+   0,                                   // tp_as_sequence
+   0,                                   // tp_as_mapping
+   0,                                   // tp_hash
+};
+
 									/*}}}*/
 // Package List Class							/*{{{*/
 // ---------------------------------------------------------------------
@@ -727,5 +747,13 @@
    if (Cache->Open(Prog,false) == false)
       return HandleErrors();
    
-   return CppOwnedPyObject_NEW<pkgCache *>(0,&PkgCacheType,(pkgCache *)(*Cache));
+   CppOwnedPyObject<pkgCacheFile> *CacheFileObj =
+	   CppOwnedPyObject_NEW<pkgCacheFile>(0,&PkgCacheFileType, *Cache);
+   
+   CppOwnedPyObject<pkgCache *> *CacheObj =
+	   CppOwnedPyObject_NEW<pkgCache *>(CacheFileObj,&PkgCacheType,
+					    (pkgCache *)(*Cache));
+
+   Py_DECREF(CacheFileObj);
+   return CacheObj;
 }

Reply to: