| 550 cx_kvl_map_iterator, |
550 cx_kvl_map_iterator, |
| 551 }; |
551 }; |
| 552 |
552 |
| 553 CxList *cxKvListCreate( |
553 CxList *cxKvListCreate( |
| 554 const CxAllocator *allocator, |
554 const CxAllocator *allocator, |
| 555 cx_compare_func comparator, |
|
| 556 size_t elem_size |
555 size_t elem_size |
| 557 ) { |
556 ) { |
| 558 if (allocator == NULL) { |
557 if (allocator == NULL) { |
| 559 allocator = cxDefaultAllocator; |
558 allocator = cxDefaultAllocator; |
| 560 } |
559 } |
| 561 |
560 |
| 562 // create a normal linked list and a normal hash map, first |
561 // create a normal linked list and a normal hash map, first |
| 563 CxList *list = cxLinkedListCreate(allocator, comparator, elem_size); |
562 CxList *list = cxLinkedListCreate(allocator, elem_size); |
| 564 if (list == NULL) return NULL; // LCOV_EXCL_LINE |
563 if (list == NULL) return NULL; // LCOV_EXCL_LINE |
| 565 cx_linked_list *ll = (cx_linked_list*)list; |
564 cx_linked_list *ll = (cx_linked_list*)list; |
| 566 cx_linked_list_extra_data(ll, sizeof(CxHashKey)); |
565 cx_linked_list_extra_data(ll, sizeof(CxHashKey)); |
| 567 CxMap *map = cxHashMapCreate(allocator, CX_STORE_POINTERS, 0); |
566 CxMap *map = cxHashMapCreate(allocator, CX_STORE_POINTERS, 0); |
| 568 if (map == NULL) { // LCOV_EXCL_START |
567 if (map == NULL) { // LCOV_EXCL_START |
| 611 return list; |
610 return list; |
| 612 } |
611 } |
| 613 |
612 |
| 614 CxMap *cxKvListCreateAsMap( |
613 CxMap *cxKvListCreateAsMap( |
| 615 const CxAllocator *allocator, |
614 const CxAllocator *allocator, |
| 616 cx_compare_func comparator, |
|
| 617 size_t elem_size |
615 size_t elem_size |
| 618 ) { |
616 ) { |
| 619 CxList *list = cxKvListCreate(allocator, comparator, elem_size); |
617 CxList *list = cxKvListCreate(allocator, elem_size); |
| 620 return list == NULL ? NULL : cxKvListAsMap(list); |
618 return list == NULL ? NULL : cxKvListAsMap(list); |
| 621 } |
619 } |
| 622 |
620 |
| 623 CxList *cxKvListAsList(CxMap *map) { |
621 CxList *cxKvListAsList(CxMap *map) { |
| 624 return &((struct cx_kv_list_map_s*)map)->list->list.base; |
622 return &((struct cx_kv_list_map_s*)map)->list->list.base; |