src/linked_list.c

changeset 412
af766caea48d
parent 409
5d167af0eadb
child 416
a79b2388db5e
     1.1 --- a/src/linked_list.c	Sun Feb 14 11:31:13 2021 +0100
     1.2 +++ b/src/linked_list.c	Sun Feb 14 15:13:53 2021 +0100
     1.3 @@ -156,30 +156,20 @@
     1.4  };
     1.5  
     1.6  CxList cxLinkedListCreate(CxAllocator allocator, CxListComparator comparator, size_t item_size) {
     1.7 -    CxLinkedListDesc desc;
     1.8 -    desc.item_size = item_size;
     1.9 -    desc.begin = NULL;
    1.10 -    desc.loc_prev = offsetof(struct cx_linked_list_node, prev);
    1.11 -    desc.loc_next = offsetof(struct cx_linked_list_node, next);
    1.12 -
    1.13 -    return cxLinkedListWrap(allocator, comparator, desc);
    1.14 -}
    1.15 -
    1.16 -CxList cxLinkedListWrap(CxAllocator allocator, CxListComparator comparator, CxLinkedListDesc desc) {
    1.17 -    CxList list = cxMalloc(allocator, sizeof(list) + sizeof(cx_linked_list));
    1.18 +    CxList list = cxMalloc(allocator, sizeof(cx_list_s) + sizeof(cx_linked_list));
    1.19      if (list == NULL)
    1.20          return NULL;
    1.21  
    1.22      list->cl = &cx_linked_list_class;
    1.23      list->data.allocator = allocator;
    1.24      list->data.cmpfunc = comparator;
    1.25 -    list->data.itemsize = desc.item_size;
    1.26 +    list->data.itemsize = item_size;
    1.27      list->data.capacity = SIZE_MAX;
    1.28  
    1.29      cx_linked_list *ll = (cx_linked_list *) list->data.listdata;
    1.30 -    ll->begin = desc.begin;
    1.31 -    ll->loc_prev = desc.loc_prev;
    1.32 -    ll->loc_next = desc.loc_next;
    1.33 +    ll->begin = NULL;
    1.34 +    ll->loc_prev = offsetof(struct cx_linked_list_node, prev);
    1.35 +    ll->loc_next = offsetof(struct cx_linked_list_node, next);
    1.36      cxLinkedListRecalculateSize(list);
    1.37  
    1.38      return list;

mercurial