summaryrefslogtreecommitdiff
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
authorChantry Xavier <shiningxc@gmail.com>2008-05-10 18:47:42 +0200
committerDan McGee <dan@archlinux.org>2008-05-13 15:49:02 -0500
commitf43805d875ad5c672afbbfff48bded2087204773 (patch)
tree6cfc9e8ea40230aa1ec3349361f6f1f1fad63f37 /lib/libalpm/handle.c
parent8248b4bfb1abe175d73e20106a18172da5296836 (diff)
downloadpacman-f43805d875ad5c672afbbfff48bded2087204773.tar.xz
Cleanup usages of alpm_list_find and alpm_list_remove.
* remove obsolete and unused *_cmp helper functions like deppkg_cmp and _alpm_grp_cmp * new alpm_list_remove_str function, used 6 times in handle.c * remove _alpm_prov_cmp / _alpm_db_whatprovides and replace them by a more general alpm_find_pkg_satisfiers with a cleaner implementation. before: alpm_db_whatprovides(db, targ) after: alpm_find_pkg_satisfiers(alpm_db_getpkgcache(db), targ) * remove satisfycmp and replace alpm_list_find + satisfycmp usage by _alpm_find_dep_satisfiers. before : alpm_list_find(_alpm_db_get_pkgcache(db), dep, satisfycmp) after : _alpm_find_dep_satisfiers(_alpm_db_get_pkgcache(db), dep) * remove _alpm_pkgname_pkg_cmp, which was used with alpm_list_remove, and use _alpm_pkg_find + alpm_list_remove with _alpm_pkg_cmp instead. This commit actually get rids of all complicated and asymmetric _cmp functions. I first thought these functions were worth it, be caused it allowed us to reuse list_find and list_remove. But this was at the detriment of the clarity and also the ease of use of these functions, dangerous because of their asymmetricity. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 247ef71d..5f209d4c 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -384,7 +384,7 @@ void SYMEXPORT alpm_option_set_cachedirs(alpm_list_t *cachedirs)
int SYMEXPORT alpm_option_remove_cachedir(const char *cachedir)
{
- void *vdata = NULL;
+ char *vdata = NULL;
char *newcachedir;
size_t cachedirlen;
/* verify cachedir ends in a '/' */
@@ -395,8 +395,7 @@ int SYMEXPORT alpm_option_remove_cachedir(const char *cachedir)
newcachedir = calloc(cachedirlen + 1, sizeof(char));
strncpy(newcachedir, cachedir, cachedirlen);
newcachedir[cachedirlen-1] = '/';
- handle->cachedirs = alpm_list_remove(handle->cachedirs, newcachedir,
- _alpm_str_cmp, &vdata);
+ handle->cachedirs = alpm_list_remove_str(handle->cachedirs, newcachedir, &vdata);
FREE(newcachedir);
if(vdata != NULL) {
FREE(vdata);
@@ -449,9 +448,8 @@ void SYMEXPORT alpm_option_set_noupgrades(alpm_list_t *noupgrade)
int SYMEXPORT alpm_option_remove_noupgrade(const char *pkg)
{
- void *vdata = NULL;
- handle->noupgrade = alpm_list_remove(handle->noupgrade, pkg,
- _alpm_str_cmp, &vdata);
+ char *vdata = NULL;
+ handle->noupgrade = alpm_list_remove_str(handle->noupgrade, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
return(1);
@@ -472,9 +470,8 @@ void SYMEXPORT alpm_option_set_noextracts(alpm_list_t *noextract)
int SYMEXPORT alpm_option_remove_noextract(const char *pkg)
{
- void *vdata = NULL;
- handle->noextract = alpm_list_remove(handle->noextract, pkg,
- _alpm_str_cmp, &vdata);
+ char *vdata = NULL;
+ handle->noextract = alpm_list_remove_str(handle->noextract, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
return(1);
@@ -495,9 +492,8 @@ void SYMEXPORT alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs)
int SYMEXPORT alpm_option_remove_ignorepkg(const char *pkg)
{
- void *vdata = NULL;
- handle->ignorepkg = alpm_list_remove(handle->ignorepkg, pkg,
- _alpm_str_cmp, &vdata);
+ char *vdata = NULL;
+ handle->ignorepkg = alpm_list_remove_str(handle->ignorepkg, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
return(1);
@@ -518,9 +514,8 @@ void SYMEXPORT alpm_option_set_holdpkgs(alpm_list_t *holdpkgs)
int SYMEXPORT alpm_option_remove_holdpkg(const char *pkg)
{
- void *vdata = NULL;
- handle->holdpkg = alpm_list_remove(handle->holdpkg, pkg,
- _alpm_str_cmp, &vdata);
+ char *vdata = NULL;
+ handle->holdpkg = alpm_list_remove_str(handle->holdpkg, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
return(1);
@@ -541,9 +536,8 @@ void SYMEXPORT alpm_option_set_ignoregrps(alpm_list_t *ignoregrps)
int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp)
{
- void *vdata = NULL;
- handle->ignoregrp = alpm_list_remove(handle->ignoregrp, grp,
- _alpm_str_cmp, &vdata);
+ char *vdata = NULL;
+ handle->ignoregrp = alpm_list_remove_str(handle->ignoregrp, grp, &vdata);
if(vdata != NULL) {
FREE(vdata);
return(1);