src/array_list.c

changeset 622
3d93cd78aa20
parent 620
f220695aded6
child 623
21082350a590
     1.1 --- a/src/array_list.c	Sun Nov 20 16:22:50 2022 +0100
     1.2 +++ b/src/array_list.c	Sun Nov 20 16:28:03 2022 +0100
     1.3 @@ -272,7 +272,21 @@
     1.4          struct cx_list_s const *list,
     1.5          struct cx_list_s const *other
     1.6  ) {
     1.7 -
     1.8 +    if (list->size == other->size) {
     1.9 +        char const *left = ((cx_array_list const *) list)->data;
    1.10 +        char const *right = ((cx_array_list const *) other)->data;
    1.11 +        for (size_t i = 0; i < list->size; i++) {
    1.12 +            int d = list->cmpfunc(left, right);
    1.13 +            if (d != 0) {
    1.14 +                return d;
    1.15 +            }
    1.16 +            left += list->itemsize;
    1.17 +            right += other->itemsize;
    1.18 +        }
    1.19 +        return 0;
    1.20 +    } else {
    1.21 +        return list->size < other->size ? -1 : 1;
    1.22 +    }
    1.23  }
    1.24  
    1.25  static void cx_arl_reverse(struct cx_list_s *list) {

mercurial