src/linked_list.c

changeset 404
86ebc3745e62
parent 403
8fa43b732980
child 406
9cbea761fbf7
equal deleted inserted replaced
403:8fa43b732980 404:86ebc3745e62
133 cx_linked_list *listdata = list->listdata; 133 cx_linked_list *listdata = list->listdata;
134 // TODO: implement using low level API 134 // TODO: implement using low level API
135 return 0; 135 return 0;
136 } 136 }
137 137
138 void *cx_ll_last(cx_list *list) {
139 cx_linked_list *ll = list->listdata;
140 struct cx_linked_list_node *last = cx_linked_list_last(
141 NULL, &ll->end, offsetof(struct cx_linked_list_node, next));
142 return &last->payload;
143 }
138 144
139 cx_list_class cx_linked_list_class = { 145 cx_list_class cx_linked_list_class = {
140 cx_ll_add, 146 cx_ll_add,
141 cx_ll_insert, 147 cx_ll_insert,
142 cx_ll_remove, 148 cx_ll_remove,
143 cx_ll_find 149 cx_ll_find,
150 cx_ll_last
144 }; 151 };
145 152
146 CxList cxLinkedListCreate(CxAllocator allocator, CxListComparator comparator, size_t itemsize) { 153 CxList cxLinkedListCreate(CxAllocator allocator, CxListComparator comparator, size_t itemsize) {
147 CxList list = cxMalloc(allocator, sizeof(list)); 154 CxList list = cxMalloc(allocator, sizeof(list));
148 if (list == NULL) 155 if (list == NULL)

mercurial