summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-09 23:00:55 +0200
committerDan McGee <dan@archlinux.org>2011-06-14 02:32:59 +0200
commitfb3ad7f8823dd3300528b44427d40e17594b1400 (patch)
tree8932518e67553383a178d23fcdd07beb24dc801e /lib/libalpm/add.c
parent01ad3faee934aa805237bf5405e7c74dc1482a17 (diff)
downloadpacman-fb3ad7f8823dd3300528b44427d40e17594b1400.tar.gz
pacman-fb3ad7f8823dd3300528b44427d40e17594b1400.tar.xz
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 <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c13
1 files changed, 7 insertions, 6 deletions
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);