src/kv_list.c

changeset 1532
313fd460d264
parent 1482
6769cb72521b
equal deleted inserted replaced
1531:3ee5a5c7823a 1532:313fd460d264
96 list->map->map_base.base.collection.destructor_data = NULL; 96 list->map->map_base.base.collection.destructor_data = NULL;
97 } 97 }
98 } 98 }
99 99
100 static CxHashKey *cx_kv_list_loc_key(cx_kv_list *list, void *node_data) { 100 static CxHashKey *cx_kv_list_loc_key(cx_kv_list *list, void *node_data) {
101 return (CxHashKey*)((char*)node_data + list->list.base.collection.elem_size); 101 return (CxHashKey*)((char*)node_data - list->list.loc_data + list->list.loc_extra);
102 } 102 }
103 103
104 static void cx_kvl_deallocate(struct cx_list_s *list) { 104 static void cx_kvl_deallocate(struct cx_list_s *list) {
105 cx_kv_list *kv_list = (cx_kv_list*)list; 105 cx_kv_list *kv_list = (cx_kv_list*)list;
106 // patch the destructors 106 // patch the destructors
557 557
558 // create a normal linked list and a normal hash map, first 558 // create a normal linked list and a normal hash map, first
559 CxList *list = cxLinkedListCreate(allocator, comparator, elem_size); 559 CxList *list = cxLinkedListCreate(allocator, comparator, elem_size);
560 if (list == NULL) return NULL; // LCOV_EXCL_LINE 560 if (list == NULL) return NULL; // LCOV_EXCL_LINE
561 cx_linked_list *ll = (cx_linked_list*)list; 561 cx_linked_list *ll = (cx_linked_list*)list;
562 ll->extra_data_len = sizeof(CxHashKey); 562 cx_linked_list_extra_data(ll, sizeof(CxHashKey));
563 CxMap *map = cxHashMapCreate(allocator, CX_STORE_POINTERS, 0); 563 CxMap *map = cxHashMapCreate(allocator, CX_STORE_POINTERS, 0);
564 if (map == NULL) { // LCOV_EXCL_START 564 if (map == NULL) { // LCOV_EXCL_START
565 cxListFree(list); 565 cxListFree(list);
566 return NULL; 566 return NULL;
567 } // LCOV_EXCL_STOP 567 } // LCOV_EXCL_STOP

mercurial