1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

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>
This commit is contained in:
Dan McGee 2007-04-26 19:57:09 -04:00
parent 75efcbbff6
commit db9e10f142
6 changed files with 19 additions and 25 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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);