Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=83f7b6bf7dee5523fdb17286cf51e1f883f19014

commit 83f7b6bf7dee5523fdb17286cf51e1f883f19014
Author: Michel Hermier <herm...@frugalware.org>
Date:   Tue May 13 14:03:20 2014 +0200

libpacman: Make __pmsyncpkg_t aquire and release pkg_new and pkg_local objects 
on constructor and destructor.

diff --git a/lib/libpacman/sync.cpp b/lib/libpacman/sync.cpp
index 19680b2..1e71a5f 100644
--- a/lib/libpacman/sync.cpp
+++ b/lib/libpacman/sync.cpp
@@ -66,16 +66,21 @@ __pmsyncpkg_t::__pmsyncpkg_t(int type, Package *spkg, void 
*data)
this->type = type;
this->pkg_name = spkg->name();
this->pkg_new = spkg;
+       this->pkg_new->acquire();
this->data = data;
-       this->pkg_local = _pacman_db_get_pkgfromcache(handle->db_local, 
this->pkg_name);
+       if((this->pkg_local = _pacman_db_get_pkgfromcache(handle->db_local, 
this->pkg_name)) != NULL) {
+               this->pkg_local->acquire();
+       }
}

__pmsyncpkg_t::~__pmsyncpkg_t()
{
if(type == PM_SYNC_TYPE_REPLACE) {
FREELISTPKGS(data);
-       } else {
-               delete (Package *)data;
+       }
+       pkg_new->release();
+       if(pkg_local != NULL) {
+               pkg_local->release();
}
}
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to