diff options
author | Dan McGee <dan@archlinux.org> | 2007-04-26 19:57:09 -0400 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-04-27 14:29:23 -0400 |
commit | db9e10f14215ab6453cd663a62cae5bdfac3d61b (patch) | |
tree | d94d3af1f79988549f50e6ea52e25da94d3f8125 /lib/libalpm | |
parent | 75efcbbff6a9e1db543f04693f70780413369a85 (diff) | |
download | pacman-db9e10f14215ab6453cd663a62cae5bdfac3d61b.tar.xz |
Remove FREETRANS macro and correctly type _alpm_trans_free
Remove an unnecessary macro, and get rid of the void pointer.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r-- | lib/libalpm/add.c | 10 | ||||
-rw-r--r-- | lib/libalpm/alpm.c | 10 | ||||
-rw-r--r-- | lib/libalpm/handle.c | 2 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 9 | ||||
-rw-r--r-- | lib/libalpm/trans.c | 4 | ||||
-rw-r--r-- | lib/libalpm/trans.h | 9 |
6 files changed, 19 insertions, 25 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 3c6aebd9..adbddb28 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -386,12 +386,14 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) } if(_alpm_trans_init(tr, PM_TRANS_TYPE_UPGRADE, trans->flags, NULL, NULL, NULL) == -1) { - FREETRANS(tr); + _alpm_trans_free(tr); + tr = NULL; RET_ERR(PM_ERR_TRANS_ABORT, -1); } if(_alpm_remove_loadtarget(tr, db, newpkg->name) == -1) { - FREETRANS(tr); + _alpm_trans_free(tr); + tr = NULL; RET_ERR(PM_ERR_TRANS_ABORT, -1); } @@ -413,7 +415,9 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) int ret = _alpm_remove_commit(tr, db); - FREETRANS(tr); + _alpm_trans_free(tr); + tr = NULL; + /* restore our "NoUpgrade" list to previous state */ alpm_list_free_inner(handle->noupgrade, free); alpm_list_free(handle->noupgrade); diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 74c07107..1b7eea59 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -99,11 +99,6 @@ int SYMEXPORT alpm_release() ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - /* free the transaction if there is any */ - if(handle->trans) { - alpm_trans_release(); - } - /* close local database */ if(handle->db_local) { alpm_db_unregister(handle->db_local); @@ -768,7 +763,7 @@ int SYMEXPORT alpm_trans_release() ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans->state != STATE_IDLE, RET_ERR(PM_ERR_TRANS_NULL, -1)); - /* during a commit do not interrupt inmediatelly, just after a target */ + /* during a commit do not interrupt immediately, just after a target */ if(trans->state == STATE_COMMITING || trans->state == STATE_INTERRUPTED) { if(trans->state == STATE_COMMITING) { trans->state = STATE_INTERRUPTED; @@ -777,7 +772,8 @@ int SYMEXPORT alpm_trans_release() return(-1); } - FREETRANS(handle->trans); + _alpm_trans_free(trans); + handle->trans = NULL; /* unlock db */ if(handle->lckfd != -1) { diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 82a52320..de80eb8f 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -104,7 +104,7 @@ int _alpm_handle_free(pmhandle_t *handle) } /* free memory */ - FREETRANS(handle->trans); + _alpm_trans_free(handle->trans); FREE(handle->root); FREE(handle->dbpath); FREE(handle->cachedir); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 4e0a1988..de235d71 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -951,7 +951,8 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) goto error; } } - FREETRANS(tr); + _alpm_trans_free(tr); + tr = NULL; /* install targets */ _alpm_log(PM_LOG_DEBUG, _("installing packages")); @@ -993,7 +994,8 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) _alpm_log(PM_LOG_ERROR, _("could not commit transaction")); goto error; } - FREETRANS(tr); + _alpm_trans_free(tr); + tr = NULL; /* propagate replaced packages' requiredby fields to their new owners */ if(replaces) { @@ -1058,7 +1060,8 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) return(0); error: - FREETRANS(tr); + _alpm_trans_free(tr); + tr = NULL; /* commiting failed, so this is still just a prepared transaction */ trans->state = STATE_PREPARED; return(-1); diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index b5dfbd96..27e22bc6 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -69,10 +69,8 @@ pmtrans_t *_alpm_trans_new() return(trans); } -void _alpm_trans_free(void *data) +void _alpm_trans_free(pmtrans_t *trans) { - pmtrans_t *trans = data; - ALPM_LOG_FUNC; if(trans == NULL) { diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h index 34a060ad..11f15f85 100644 --- a/lib/libalpm/trans.h +++ b/lib/libalpm/trans.h @@ -50,13 +50,6 @@ struct __pmtrans_t { alpm_trans_cb_progress cb_progress; }; -#define FREETRANS(p) \ -do { \ - if(p) { \ - _alpm_trans_free(p); \ - p = NULL; \ - } \ -} while (0) #define EVENT(t, e, d1, d2) \ do { \ if((t) && (t)->cb_event) { \ @@ -77,7 +70,7 @@ do { \ } while(0) pmtrans_t *_alpm_trans_new(void); -void _alpm_trans_free(void *data); +void _alpm_trans_free(pmtrans_t *trans); int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, pmtransflag_t flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress); |