From 5ef51b3e266cf43411947248886372001fdb207a Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Fri, 7 Oct 2005 23:29:49 +0000 Subject: Merging in recent fixes/additions from 2.9.7 --- lib/libalpm/list.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/libalpm/list.c') 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 -- cgit v1.2.3