src/array_list.c

changeset 622
3d93cd78aa20
parent 620
f220695aded6
child 623
21082350a590
--- a/src/array_list.c	Sun Nov 20 16:22:50 2022 +0100
+++ b/src/array_list.c	Sun Nov 20 16:28:03 2022 +0100
@@ -272,7 +272,21 @@
         struct cx_list_s const *list,
         struct cx_list_s const *other
 ) {
-
+    if (list->size == other->size) {
+        char const *left = ((cx_array_list const *) list)->data;
+        char const *right = ((cx_array_list const *) other)->data;
+        for (size_t i = 0; i < list->size; i++) {
+            int d = list->cmpfunc(left, right);
+            if (d != 0) {
+                return d;
+            }
+            left += list->itemsize;
+            right += other->itemsize;
+        }
+        return 0;
+    } else {
+        return list->size < other->size ? -1 : 1;
+    }
 }
 
 static void cx_arl_reverse(struct cx_list_s *list) {

mercurial