aboutsummaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.c')
-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)
200 return ep ? ep->data : NULL; 200 return ep ? ep->data : NULL;
201} 201}
202 202
203int
204grecs_list_compare(struct grecs_list *a, struct grecs_list *b)
205{
206 struct grecs_list_entry *ap, *bp;
207 int (*cmp)(const void *, const void *);
208
209 if (!a)
210 return !!b;
211 else if (!b)
212 return 1;
213
214 if (grecs_list_size(a) != grecs_list_size(b))
215 return 1;
216 if (a->cmp != b->cmp)
217 return 1;
218
219 cmp = a->cmp ? a->cmp : _ptrcmp;
220
221 for (ap = a->head, bp = b->head; ap; ap = ap->next, bp = bp->next)
222 if (cmp (ap->data, bp->data))
223 return 1;
224
225 return 0;
226}
227

Return to:

Send suggestions and report system problems to the System administrator.