src/array_list.c

changeset 629
6c81ee4f11ad
parent 628
1e2be40f0cb5
child 630
ac5e7f789048
     1.1 --- a/src/array_list.c	Sun Nov 20 21:08:36 2022 +0100
     1.2 +++ b/src/array_list.c	Wed Nov 23 22:40:55 2022 +0100
     1.3 @@ -185,6 +185,29 @@
     1.4      );
     1.5  }
     1.6  
     1.7 +static size_t cx_arl_add_array(
     1.8 +        struct cx_list_s *list,
     1.9 +        void const *array,
    1.10 +        size_t n
    1.11 +) {
    1.12 +    cx_array_list *arl = (cx_array_list *) list;
    1.13 +    if (CX_ARRAY_COPY_SUCCESS == cx_array_copy(
    1.14 +            &arl->data,
    1.15 +            &list->size,
    1.16 +            &list->capacity,
    1.17 +            list->size,
    1.18 +            array,
    1.19 +            list->itemsize,
    1.20 +            n,
    1.21 +            &arl->reallocator
    1.22 +    )) {
    1.23 +        return n;
    1.24 +    } else {
    1.25 +        // array list implementation is "all or nothing"
    1.26 +        return 0;
    1.27 +    }
    1.28 +}
    1.29 +
    1.30  static int cx_arl_insert(
    1.31          struct cx_list_s *list,
    1.32          size_t index,
    1.33 @@ -385,6 +408,7 @@
    1.34  static cx_list_class cx_array_list_class = {
    1.35          cx_arl_destructor,
    1.36          cx_arl_add,
    1.37 +        cx_arl_add_array,
    1.38          cx_arl_insert,
    1.39          cx_arl_insert_iter,
    1.40          cx_arl_remove,

mercurial