From 04e054f3cbc9ddda9d99e4891055ae2743b3b8ff Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Wed, 6 Apr 2005 18:25:33 +0000 Subject: replaced transaction 'packages' field by 2 queues: one for packages to be installed and the other for the ones to be removed --- lib/libalpm/trans.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'lib/libalpm/trans.c') diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 6e278cd7..af0c6b7d 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -45,7 +45,8 @@ pmtrans_t *trans_new() } trans->targets = NULL; - trans->packages = NULL; + trans->install_q = NULL; + trans->remove_q = NULL; trans->type = 0; trans->flags = 0; trans->cb = NULL; @@ -63,9 +64,17 @@ void trans_free(pmtrans_t *trans) FREELIST(trans->targets); /* ORE - ugly */ if(trans->type == PM_TRANS_TYPE_SYNC) { - FREELISTPTR(trans->packages); + PMList *i = trans->install_q; + while(i) { + PMList *j = i->next; + sync_free(i->data); + i->data = NULL; + pm_list_free(i); + i = j; + } } else { - FREELISTPKGS(trans->packages); + FREELISTPKGS(trans->install_q); + FREELISTPKGS(trans->remove_q); } free(trans); @@ -133,7 +142,9 @@ int trans_prepare(pmtrans_t *trans, PMList **data) /* Sanity checks */ ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - ASSERT(trans->packages != NULL, return(0)); + if(trans->install_q == NULL && trans->remove_q == NULL) { + return(0); + } switch(trans->type) { case PM_TRANS_TYPE_ADD: @@ -168,7 +179,9 @@ int trans_commit(pmtrans_t *trans) ASSERT(trans != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); /* If there's nothing to do, return without complaining */ - ASSERT(trans->packages != NULL, return(0)); + if(trans->install_q == NULL && trans->remove_q == NULL) { + return(0); + } switch(trans->type) { case PM_TRANS_TYPE_ADD: -- cgit v1.2.3-54-g00ecf