summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorNagy Gabor <ngaba@bibl.u-szeged.hu>2008-07-01 22:53:13 +0200
committerDan McGee <dan@archlinux.org>2008-07-08 04:04:16 +0200
commitf7199f36ba5a2b42da51cd227855caaa43c51d58 (patch)
treee2b6a461fdde5e0bb480c9650cbf93361def7ec0 /lib/libalpm/package.c
parent2122eb1428ac754e9f5d675b4c4fa62b0286d3b6 (diff)
downloadpacman-f7199f36ba5a2b42da51cd227855caaa43c51d58.tar.gz
pacman-f7199f36ba5a2b42da51cd227855caaa43c51d58.tar.xz
New _alpm_dep_edge function
The function is introduced to kill some code duplication. The function name uses the 'dependency graph' terminology. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 79cc64e5..124d89a0 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -540,7 +540,7 @@ unsigned short SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)
*/
alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
{
- const alpm_list_t *i, *j;
+ const alpm_list_t *i;
alpm_list_t *reqs = NULL;
pmdb_t *localdb = alpm_option_get_localdb();
@@ -549,17 +549,9 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
continue;
}
pmpkg_t *cachepkg = i->data;
- const char *cachepkgname = alpm_pkg_get_name(cachepkg);
-
- for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) {
- pmdepend_t *dep = j->data;
-
- if(alpm_depcmp(pkg, dep)) {
- _alpm_log(PM_LOG_DEBUG, "adding '%s' in requiredby field for '%s'\n",
- cachepkgname, pkg->name);
- reqs = alpm_list_add(reqs, strdup(cachepkgname));
- break;
- }
+ if(_alpm_dep_edge(cachepkg, pkg)) {
+ const char *cachepkgname = alpm_pkg_get_name(cachepkg);
+ reqs = alpm_list_add(reqs, strdup(cachepkgname));
}
}
return(reqs);