From 8bee526d28eaad45e0e1e210cd523e157c71cfae Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Wed, 21 Nov 2007 17:10:20 +0100 Subject: Fix a memleak in _alpm_sync_free. An alpm_list_free call was missing. Also make use of alpm_list_free_inner in both _alpm_sync_free and _alpm_trans_free. Signed-off-by: Chantry Xavier Signed-off-by: Dan McGee --- lib/libalpm/sync.c | 7 ++----- lib/libalpm/trans.c | 10 ++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 16b1998d..f03a78be 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -74,11 +74,8 @@ void _alpm_sync_free(pmsyncpkg_t *sync) /* TODO wow this is ugly */ if(sync->type == PM_SYNC_TYPE_REPLACE) { - alpm_list_t *tmp; - for(tmp = sync->data; tmp; tmp = alpm_list_next(tmp)) { - _alpm_pkg_free(tmp->data); - tmp->data = NULL; - } + alpm_list_free_inner(sync->data, (alpm_list_fn_free)_alpm_pkg_free); + alpm_list_free(sync->data); sync->data = NULL; } else { _alpm_pkg_free(sync->data); diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 19ae2b6c..d9988265 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -246,8 +246,6 @@ pmtrans_t *_alpm_trans_new() void _alpm_trans_free(pmtrans_t *trans) { - alpm_list_t *i; - ALPM_LOG_FUNC; if(trans == NULL) { @@ -256,13 +254,9 @@ void _alpm_trans_free(pmtrans_t *trans) FREELIST(trans->targets); if(trans->type == PM_TRANS_TYPE_SYNC) { - for(i = trans->packages; i; i = alpm_list_next(i)) { - _alpm_sync_free(i->data); - } + alpm_list_free_inner(trans->packages, (alpm_list_fn_free)_alpm_sync_free); } else { - for(i = trans->packages; i; i = alpm_list_next(i)) { - _alpm_pkg_free(i->data); - } + alpm_list_free_inner(trans->packages, (alpm_list_fn_free)_alpm_pkg_free); } alpm_list_free(trans->packages); -- cgit v1.2.3-70-g09d2