New _alpm_find_dep_satisfier function
This function finds the first satisfier package in a pkglist. Using it instead of _alpm_find_dep_satisfiers eliminates some memleaks and it is faster. (_alpm_find_dep_satisfiers and _alpm_find_pkg_satisfiers will be removed soon.) Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
f7199f36ba
commit
616b5967b8
2 changed files with 20 additions and 6 deletions
|
@ -189,6 +189,19 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse)
|
||||||
return(newtargs);
|
return(newtargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pmpkg_t *_alpm_find_dep_satisfier(alpm_list_t *pkgs, pmdepend_t *dep)
|
||||||
|
{
|
||||||
|
alpm_list_t *i;
|
||||||
|
|
||||||
|
for(i = pkgs; i; i = alpm_list_next(i)) {
|
||||||
|
pmpkg_t *pkg = i->data;
|
||||||
|
if(alpm_depcmp(pkg, dep)) {
|
||||||
|
return(pkg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
alpm_list_t *_alpm_find_dep_satisfiers(alpm_list_t *pkgs, pmdepend_t *dep)
|
alpm_list_t *_alpm_find_dep_satisfiers(alpm_list_t *pkgs, pmdepend_t *dep)
|
||||||
{
|
{
|
||||||
alpm_list_t *i, *ret = NULL;
|
alpm_list_t *i, *ret = NULL;
|
||||||
|
@ -232,7 +245,7 @@ alpm_list_t SYMEXPORT *alpm_deptest(pmdb_t *db, alpm_list_t *targets)
|
||||||
target = alpm_list_getdata(i);
|
target = alpm_list_getdata(i);
|
||||||
dep = _alpm_splitdep(target);
|
dep = _alpm_splitdep(target);
|
||||||
|
|
||||||
if(!_alpm_find_dep_satisfiers(_alpm_db_get_pkgcache(db), dep)) {
|
if(!_alpm_find_dep_satisfier(_alpm_db_get_pkgcache(db), dep)) {
|
||||||
ret = alpm_list_add(ret, target);
|
ret = alpm_list_add(ret, target);
|
||||||
}
|
}
|
||||||
_alpm_dep_free(dep);
|
_alpm_dep_free(dep);
|
||||||
|
@ -283,8 +296,8 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
|
||||||
pmdepend_t *depend = j->data;
|
pmdepend_t *depend = j->data;
|
||||||
/* 1. we check the upgrade list */
|
/* 1. we check the upgrade list */
|
||||||
/* 2. we check database for untouched satisfying packages */
|
/* 2. we check database for untouched satisfying packages */
|
||||||
if(!_alpm_find_dep_satisfiers(upgrade, depend) &&
|
if(!_alpm_find_dep_satisfier(upgrade, depend) &&
|
||||||
!_alpm_find_dep_satisfiers(dblist, depend)) {
|
!_alpm_find_dep_satisfier(dblist, depend)) {
|
||||||
/* Unsatisfied dependency in the upgrade list */
|
/* Unsatisfied dependency in the upgrade list */
|
||||||
char *missdepstring = alpm_dep_get_string(depend);
|
char *missdepstring = alpm_dep_get_string(depend);
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkdeps: missing dependency '%s' for package '%s'\n",
|
_alpm_log(PM_LOG_DEBUG, "checkdeps: missing dependency '%s' for package '%s'\n",
|
||||||
|
@ -303,13 +316,13 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(pmdb_t *db, int reversedeps,
|
||||||
pmpkg_t *lp = i->data;
|
pmpkg_t *lp = i->data;
|
||||||
for(j = alpm_pkg_get_depends(lp); j; j = j->next) {
|
for(j = alpm_pkg_get_depends(lp); j; j = j->next) {
|
||||||
pmdepend_t *depend = j->data;
|
pmdepend_t *depend = j->data;
|
||||||
pmpkg_t *causingpkg = alpm_list_getdata(_alpm_find_dep_satisfiers(modified, depend));
|
pmpkg_t *causingpkg = _alpm_find_dep_satisfier(modified, depend);
|
||||||
/* we won't break this depend, if it is already broken, we ignore it */
|
/* we won't break this depend, if it is already broken, we ignore it */
|
||||||
/* 1. check upgrade list for satisfiers */
|
/* 1. check upgrade list for satisfiers */
|
||||||
/* 2. check dblist for satisfiers */
|
/* 2. check dblist for satisfiers */
|
||||||
if(causingpkg &&
|
if(causingpkg &&
|
||||||
!_alpm_find_dep_satisfiers(upgrade, depend) &&
|
!_alpm_find_dep_satisfier(upgrade, depend) &&
|
||||||
!_alpm_find_dep_satisfiers(dblist, depend)) {
|
!_alpm_find_dep_satisfier(dblist, depend)) {
|
||||||
char *missdepstring = alpm_dep_get_string(depend);
|
char *missdepstring = alpm_dep_get_string(depend);
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkdeps: transaction would break '%s' dependency of '%s'\n",
|
_alpm_log(PM_LOG_DEBUG, "checkdeps: transaction would break '%s' dependency of '%s'\n",
|
||||||
missdepstring, alpm_pkg_get_name(lp));
|
missdepstring, alpm_pkg_get_name(lp));
|
||||||
|
|
|
@ -52,6 +52,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
|
||||||
**data);
|
**data);
|
||||||
int _alpm_dep_edge(pmpkg_t *pkg1, pmpkg_t *pkg2);
|
int _alpm_dep_edge(pmpkg_t *pkg1, pmpkg_t *pkg2);
|
||||||
pmdepend_t *_alpm_splitdep(const char *depstring);
|
pmdepend_t *_alpm_splitdep(const char *depstring);
|
||||||
|
pmpkg_t *_alpm_find_dep_satisfier(alpm_list_t *pkgs, pmdepend_t *dep);
|
||||||
alpm_list_t *_alpm_find_dep_satisfiers(alpm_list_t *pkgs, pmdepend_t *dep);
|
alpm_list_t *_alpm_find_dep_satisfiers(alpm_list_t *pkgs, pmdepend_t *dep);
|
||||||
|
|
||||||
#endif /* _ALPM_DEPS_H */
|
#endif /* _ALPM_DEPS_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue