summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/list.c
diff options
context:
space:
mode:
authorJudd Vinet <judd@archlinux.org>2005-10-08 01:29:49 +0200
committerJudd Vinet <judd@archlinux.org>2005-10-08 01:29:49 +0200
commit5ef51b3e266cf43411947248886372001fdb207a (patch)
tree8d255349530045686053faacd1804502a96b269c /lib/libalpm/list.c
parent79031ccd1a544475162facb8ca3d671f3464d1f8 (diff)
downloadpacman-5ef51b3e266cf43411947248886372001fdb207a.tar.gz
pacman-5ef51b3e266cf43411947248886372001fdb207a.tar.xz
Merging in recent fixes/additions from 2.9.7
Diffstat (limited to 'lib/libalpm/list.c')
-rw-r--r--lib/libalpm/list.c18
1 files changed, 18 insertions, 0 deletions
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