From fb3ad7f8823dd3300528b44427d40e17594b1400 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 9 Jun 2011 16:00:55 -0500 Subject: Add handle argument to alpm_(add|remove)_pkg() This makes these functions consistent with the rest of the transaction related API calls. We do an additional assert to ensure the handle attached to the package is the same as the handle passed in. Signed-off-by: Dan McGee --- lib/libalpm/add.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/libalpm/add.c') diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 6edceca1..008144b9 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -48,19 +48,20 @@ #include "handle.h" /** Add a package to the transaction. */ -int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg) +int SYMEXPORT alpm_add_pkg(pmhandle_t *handle, pmpkg_t *pkg) { const char *pkgname, *pkgver; pmtrans_t *trans; - pmdb_t *db_local; pmpkg_t *local; /* Sanity checks */ + ASSERT(handle != NULL, return -1); ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - trans = pkg->handle->trans; + ASSERT(handle == pkg->handle, RET_ERR(PM_ERR_WRONG_ARGS, -1)); + trans = handle->trans; ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); - ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1)); - db_local = pkg->handle->db_local; + ASSERT(trans->state == STATE_INITIALIZED, + RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1)); pkgname = pkg->name; pkgver = pkg->version; @@ -71,7 +72,7 @@ int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg) RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1); } - local = _alpm_db_get_pkgfromcache(db_local, pkgname); + local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname); if(local) { const char *localpkgname = alpm_pkg_get_name(local); const char *localpkgver = alpm_pkg_get_version(local); -- cgit v1.2.3