Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChantry Xavier <shiningxc@gmail.com>2008-01-12 21:28:22 +0100
committerDan McGee <dan@archlinux.org>2008-01-23 20:13:01 -0600
commit8240da6cb3ff95ad480efe3e1876104024398fae (patch)
tree124bf5ca94dbfa3aa8361fd20ec066b784770581
parentbd43a7f155cbd54d58fb45285e2eef1f51c88b00 (diff)
libalpm/cache.c : don't duplicate packages in pkgcache.
Edit _alpm_db_add_pkgincache to not duplicate packages, because this is not needed, is slower, and uses more memory. This made the max memory usage during base reinstall go from 10.4MB to 9.7MB. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/cache.c15
-rw-r--r--lib/libalpm/trans.c3
2 files changed, 5 insertions, 13 deletions
diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c
index 0ad923a5..09fa74c2 100644
--- a/lib/libalpm/cache.c
+++ b/lib/libalpm/cache.c
@@ -81,10 +81,7 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
_alpm_log(PM_LOG_DEBUG, "freeing package cache for repository '%s'\n",
db->treename);
- alpm_list_t *tmp;
- for(tmp = db->pkgcache; tmp; tmp = alpm_list_next(tmp)) {
- _alpm_pkg_free(tmp->data);
- }
+ alpm_list_free_inner(db->pkgcache, (alpm_list_fn_free)_alpm_pkg_free);
alpm_list_free(db->pkgcache);
db->pkgcache = NULL;
@@ -115,21 +112,15 @@ alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db)
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
{
- pmpkg_t *newpkg;
-
ALPM_LOG_FUNC;
if(db == NULL || pkg == NULL) {
return(-1);
}
- newpkg = _alpm_pkg_dup(pkg);
- if(newpkg == NULL) {
- return(-1);
- }
_alpm_log(PM_LOG_DEBUG, "adding entry '%s' in '%s' cache\n",
- alpm_pkg_get_name(newpkg), db->treename);
- db->pkgcache = alpm_list_add_sorted(db->pkgcache, newpkg, _alpm_pkg_cmp);
+ alpm_pkg_get_name(pkg), db->treename);
+ db->pkgcache = alpm_list_add_sorted(db->pkgcache, pkg, _alpm_pkg_cmp);
_alpm_db_free_grpcache(db);
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index ecc40a0f..52dbe7a9 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -253,7 +253,8 @@ void _alpm_trans_free(pmtrans_t *trans)
FREELIST(trans->targets);
if(trans->type == PM_TRANS_TYPE_SYNC) {
alpm_list_free_inner(trans->packages, (alpm_list_fn_free)_alpm_sync_free);
- } else {
+ } else if (trans->type == PM_TRANS_TYPE_REMOVE ||
+ trans->type == PM_TRANS_TYPE_REMOVEUPGRADE) {
alpm_list_free_inner(trans->packages, (alpm_list_fn_free)_alpm_pkg_free);
}
alpm_list_free(trans->packages);