- fixed memory leak in PersistentStorage (#168690)
authorMichael Andres <ma@suse.de>
Tue, 6 Jun 2006 22:03:37 +0000 (22:03 +0000)
committerMichael Andres <ma@suse.de>
Tue, 6 Jun 2006 22:03:37 +0000 (22:03 +0000)
package/libzypp.changes
zypp/target/store/PersistentStorage.cc
zypp/target/store/PersistentStorage.h

index c19d8fd..e15fc0a 100644 (file)
@@ -1,4 +1,9 @@
 -------------------------------------------------------------------
+Wed Jun  7 00:02:18 CEST 2006 - ma@suse.de
+
+- fixed memory leak in PersistentStorage (#168690)
+
+-------------------------------------------------------------------
 Tue Jun  6 22:24:00 CEST 2006 - ma@suse.de
 
 - fixed memory leak in XMLSourceCacheParser (#168690)
index 8dd761f..708b355 100644 (file)
@@ -29,10 +29,9 @@ namespace storage
 //     CLASS NAME : PersistentStoragePrivate
 //
 ///////////////////////////////////////////////////////////////////
-class PersistentStorage::Private
+struct PersistentStorage::Private
 {
-  public:
-  Backend *backend;
+  shared_ptr<Backend> backend;
 };
 
 ///////////////////////////////////////////////////////////////////
@@ -47,20 +46,19 @@ class PersistentStorage::Private
 //     METHOD TYPE : Ctor
 //
 PersistentStorage::PersistentStorage()
+: d( new Private )
 {
-  d = new Private;
   DBG << "  Creating XML Files backend" << endl;
-  d->backend = 0L;
 }
 
 void PersistentStorage::init(const Pathname &root)
 {
-  d->backend = new XMLFilesBackend(root);
+  d->backend.reset( new XMLFilesBackend(root) );
 }
 
 bool PersistentStorage::isInitialized() const
 {
-  return ! (d->backend == 0L);
+  return d->backend;
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -137,7 +135,7 @@ PersistentStorage::doesObjectHasFlag( ResObject::constPtr resolvable, const std:
 // Named Flags API
 ////////////////////////////////////////////////////////
 
-void 
+void
 PersistentStorage::setFlag( const std::string &key, const std::string &flag )
 {
   d->backend->setFlag(key, flag);
index 418225b..baa369c 100644 (file)
@@ -43,7 +43,7 @@ namespace zypp
       /** Dtor */
       ~PersistentStorage();
       void doTest();
-      
+
       struct SourceData
       {
         SourceData()
@@ -51,7 +51,7 @@ namespace zypp
           enabled = true;
           autorefresh = false;
         };
-       
+
         bool enabled;
         bool autorefresh;
         Pathname product_dir;
@@ -142,7 +142,7 @@ namespace zypp
 
     private:
       class Private;
-      Private *d;
+      shared_ptr<Private> d;
     };
     ///////////////////////////////////////////////////////////////////
     /** \relates PersistentStorage Stream output */