summaryrefslogtreecommitdiffabout
path: root/src/list.c
Side-by-side diff
Diffstat (limited to 'src/list.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/list.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/list.c b/src/list.c
index 2d57fe0..f6aa6ad 100644
--- a/src/list.c
+++ b/src/list.c
@@ -200,3 +200,28 @@ grecs_list_index(struct grecs_list *lp, size_t idx)
return ep ? ep->data : NULL;
}
+int
+grecs_list_compare(struct grecs_list *a, struct grecs_list *b)
+{
+ struct grecs_list_entry *ap, *bp;
+ int (*cmp)(const void *, const void *);
+
+ if (!a)
+ return !!b;
+ else if (!b)
+ return 1;
+
+ if (grecs_list_size(a) != grecs_list_size(b))
+ return 1;
+ if (a->cmp != b->cmp)
+ return 1;
+
+ cmp = a->cmp ? a->cmp : _ptrcmp;
+
+ for (ap = a->head, bp = b->head; ap; ap = ap->next, bp = bp->next)
+ if (cmp (ap->data, bp->data))
+ return 1;
+
+ return 0;
+}
+

Return to:

Send suggestions and report system problems to the System administrator.