src/array_list.c

changeset 1657
c6a0381ab9b7
parent 1656
68a03cf89e15
child 1658
71aa6e28a2d7
equal deleted inserted replaced
1656:68a03cf89e15 1657:c6a0381ab9b7
1071 allocator = cxDefaultAllocator; 1071 allocator = cxDefaultAllocator;
1072 } 1072 }
1073 1073
1074 cx_array_list *list = cxCalloc(allocator, 1, sizeof(cx_array_list)); 1074 cx_array_list *list = cxCalloc(allocator, 1, sizeof(cx_array_list));
1075 if (list == NULL) return NULL; 1075 if (list == NULL) return NULL;
1076 cx_list_init((CxList*)list, &cx_array_list_class, 1076 cx_list_init((CxList*)list, &cx_array_list_class, allocator, elem_size);
1077 allocator, elem_size);
1078 list->capacity = initial_capacity; 1077 list->capacity = initial_capacity;
1079 1078
1080 // allocate the array after the real elem_size is known 1079 // allocate the array after the real elem_size is known
1081 list->data = cxCalloc(allocator, initial_capacity, 1080 list->data = cxCalloc(allocator, initial_capacity, elem_size);
1082 list->base.collection.elem_size);
1083 if (list->data == NULL) { // LCOV_EXCL_START 1081 if (list->data == NULL) { // LCOV_EXCL_START
1084 cxFree(allocator, list); 1082 cxFree(allocator, list);
1085 return NULL; 1083 return NULL;
1086 } // LCOV_EXCL_STOP 1084 } // LCOV_EXCL_STOP
1087 1085

mercurial