diff options
author | Aurelien Foret <aurelien@archlinux.org> | 2005-05-03 17:43:02 +0000 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2005-05-03 17:43:02 +0000 |
commit | 54f6a1cb12c7e980eac903d4e6af4fe6e7e6b125 (patch) | |
tree | cda33596072eaa74d1179d31bfea5951ade86fd3 /lib/libalpm/alpm.c | |
parent | 00b97ee35f0bff40646da6766002eb0c200d96c1 (diff) | |
download | pacman-54f6a1cb12c7e980eac903d4e6af4fe6e7e6b125.tar.xz |
make use of the new list_remove implementation
Diffstat (limited to 'lib/libalpm/alpm.c')
-rw-r--r-- | lib/libalpm/alpm.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 31cfbc56..6c79c30b 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -193,9 +193,15 @@ pmdb_t *alpm_db_register(char *treename) return(db); } +/* Helper function for comparing databases + */ +static int db_cmp(const void *db1, const void *db2) +{ + return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename)); +} + int alpm_db_unregister(pmdb_t *db) { - PMList *i; int found = 0; /* Sanity checks */ @@ -207,12 +213,11 @@ int alpm_db_unregister(pmdb_t *db) handle->db_local = NULL; found = 1; } else { - for(i = handle->dbs_sync; i && !found; i = i->next) { - if(db == i->data) { - db_close(i->data); - handle->dbs_sync = _alpm_list_remove(handle->dbs_sync, i); - found = 1; - } + void *data; + handle->dbs_sync = _alpm_list_remove(handle->dbs_sync, db, db_cmp, &data); + if(data) { + db_close(data); + found = 1; } } |