src/linked_list.c

changeset 763
741a2040fa33
parent 735
b686d0c98c62
child 764
ccbdbd088455
equal deleted inserted replaced
762:4523f6d42512 763:741a2040fa33
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "cx/linked_list.h" 29 #include "cx/linked_list.h"
30 #include "cx/utils.h" 30 #include "cx/utils.h"
31 #include "cx/compare.h"
31 #include <string.h> 32 #include <string.h>
32 #include <assert.h> 33 #include <assert.h>
33 34
34 // LOW LEVEL LINKED LIST FUNCTIONS 35 // LOW LEVEL LINKED LIST FUNCTIONS
35 36
913 cx_linked_list *list = cxCalloc(allocator, 1, sizeof(cx_linked_list)); 914 cx_linked_list *list = cxCalloc(allocator, 1, sizeof(cx_linked_list));
914 if (list == NULL) return NULL; 915 if (list == NULL) return NULL;
915 916
916 list->base.cl = &cx_linked_list_class; 917 list->base.cl = &cx_linked_list_class;
917 list->base.allocator = allocator; 918 list->base.allocator = allocator;
918 list->base.cmpfunc = comparator;
919 919
920 if (item_size > 0) { 920 if (item_size > 0) {
921 list->base.item_size = item_size; 921 list->base.item_size = item_size;
922 } else { 922 list->base.cmpfunc = comparator;
923 } else {
924 list->base.cmpfunc = comparator == NULL ? cx_cmp_ptr : comparator;
923 cxListStorePointers((CxList *) list); 925 cxListStorePointers((CxList *) list);
924 } 926 }
925 927
926 return (CxList *) list; 928 return (CxList *) list;
927 } 929 }

mercurial