From e71618ff4a8bc01093bb83406a9b26640d2e1e4d Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Wed, 24 Nov 2004 10:00:30 +0000 Subject: Manuel Estrada Sainz's patch to fix memory leak with Tm... Author: jgg Date: 2002-07-08 03:24:48 GMT Manuel Estrada Sainz's patch to fix memory leak with TmpGetCache. --- python/cache.cc | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/cache.cc b/python/cache.cc index c17226b8..ee538c2a 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: cache.cc,v 1.3 2002/02/26 01:36:15 mdz Exp $ +// $Id: cache.cc,v 1.4 2002/07/08 03:24:48 jgg Exp $ /* ###################################################################### Cache - Wrapper for the cache related functions @@ -142,7 +142,28 @@ PyTypeObject PkgCacheType = &CacheMap, // tp_as_mapping 0, // tp_hash }; - + /*}}}*/ +// PkgCacheFile Class /*{{{*/ +// --------------------------------------------------------------------- +PyTypeObject PkgCacheFileType = +{ + PyObject_HEAD_INIT(&PyType_Type) + 0, // ob_size + "pkgCacheFile", // tp_name + sizeof(CppOwnedPyObject), // tp_basicsize + 0, // tp_itemsize + // Methods + CppOwnedDealloc, // 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 +748,13 @@ PyObject *TmpGetCache(PyObject *Self,PyObject *Args) if (Cache->Open(Prog,false) == false) return HandleErrors(); - return CppOwnedPyObject_NEW(0,&PkgCacheType,(pkgCache *)(*Cache)); + CppOwnedPyObject *CacheFileObj = + CppOwnedPyObject_NEW(0,&PkgCacheFileType, *Cache); + + CppOwnedPyObject *CacheObj = + CppOwnedPyObject_NEW(CacheFileObj,&PkgCacheType, + (pkgCache *)(*Cache)); + + Py_DECREF(CacheFileObj); + return CacheObj; } -- cgit v1.2.3