index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/list.c | 18 |
diff --git a/lib/libalpm/list.c b/lib/libalpm/list.c index 9d3f4005..8bf0d702 100644 --- a/lib/libalpm/list.c +++ b/lib/libalpm/list.c @@ -256,6 +256,24 @@ PMList* pm_list_last(PMList *list) return(list->last); } +/* Filter out any duplicate strings in a list. + * + * Not the most efficient way, but simple to implement -- we assemble + * a new list, using is_in() to check for dupes at each iteration. + * + */ +PMList *_alpm_list_remove_dupes(PMList *list) +{ + PMList *i, *newlist = NULL; + + for(i = list; i; i = i->next) { + if(!pm_list_is_strin(i->data, newlist)) { + newlist = pm_list_add(newlist, strdup(i->data)); + } + } + return newlist; +} + /* Reverse the order of a list * * The caller is responsible for freeing the old list |