src/array_list.c

changeset 763
741a2040fa33
parent 735
b686d0c98c62
child 764
ccbdbd088455
     1.1 --- a/src/array_list.c	Mon Dec 18 16:04:21 2023 +0100
     1.2 +++ b/src/array_list.c	Mon Dec 18 16:14:07 2023 +0100
     1.3 @@ -27,6 +27,7 @@
     1.4   */
     1.5  
     1.6  #include "cx/array_list.h"
     1.7 +#include "cx/compare.h"
     1.8  #include <assert.h>
     1.9  #include <string.h>
    1.10  
    1.11 @@ -522,13 +523,14 @@
    1.12  
    1.13      list->base.cl = &cx_array_list_class;
    1.14      list->base.allocator = allocator;
    1.15 -    list->base.cmpfunc = comparator;
    1.16      list->capacity = initial_capacity;
    1.17  
    1.18      if (item_size > 0) {
    1.19          list->base.item_size = item_size;
    1.20 +        list->base.cmpfunc = comparator;
    1.21      } else {
    1.22          item_size = sizeof(void *);
    1.23 +        list->base.cmpfunc = comparator == NULL ? cx_cmp_ptr : comparator;
    1.24          cxListStorePointers((CxList *) list);
    1.25      }
    1.26  

mercurial