aboutsummaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2016-01-21 08:19:17 +0200
committerSergey Poznyakoff <gray@gnu.org>2016-01-21 08:19:17 +0200
commit08070e48d83cd34cddb08be33cf4993fc096c9c4 (patch)
treed030a0ce61e82f668c369420b68369cec3d3ab66 /src/list.c
parentca94270a5e30add9b364d32220fb38d457ebd3f2 (diff)
downloadgrecs-08070e48d83cd34cddb08be33cf4993fc096c9c4.tar.gz
grecs-08070e48d83cd34cddb08be33cf4993fc096c9c4.tar.bz2
Implement grecs_list_compare; other minor fixes.
* src/grecs.hin (grecs_list_compare) (grecs_node_unlink): New protos. * src/list.c (grecs_list_compare): New function. * src/wordsplit.c (wordsplit_getwords): Word count is size_t * src/wordsplit.h (wordsplit_getwords): Fix proto.
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)
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.