Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/alpm_list.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/alpm_list.c')
-rw-r--r--lib/libalpm/alpm_list.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index e118a129..8c387eed 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -457,6 +457,33 @@ int alpm_list_find_str(alpm_list_t *haystack, const char *needle)
return(0);
}
+/**
+ * Calculate the items in list `lhs` that are not present in list `rhs`
+ * @note Entries are not duplicated
+ * @param lhs the first list
+ * @param rhs the second list
+ * @param fn the comparisson function
+ * @return a list containing all items in lhs not present in rhs
+ */
+alpm_list_t *alpm_list_diff(alpm_list_t *lhs, alpm_list_t *rhs, alpm_list_fn_cmp fn)
+{
+ alpm_list_t *i, *j, *ret = NULL;
+ for(i = lhs; i; i = i->next) {
+ int found = 0;
+ for(j = rhs; j; j = j->next) {
+ if(fn(i->data, j->data) == 0) {
+ found = 1;
+ break;
+ }
+ }
+ if(!found) {
+ ret = alpm_list_add(ret, i->data);
+ }
+ }
+
+ return(ret);
+}
+
/** @} */
/* vim: set ts=2 sw=2 noet: */