src/array_list.c

changeset 619
5e58187ac707
parent 616
af7d8a29fbc5
child 620
f220695aded6
     1.1 --- a/src/array_list.c	Sun Nov 20 15:51:02 2022 +0100
     1.2 +++ b/src/array_list.c	Sun Nov 20 16:21:03 2022 +0100
     1.3 @@ -183,7 +183,23 @@
     1.4          void const *elem,
     1.5          int prepend
     1.6  ) {
     1.7 -    return 1;
     1.8 +    struct cx_list_s *list = iter->src_handle;
     1.9 +    if (iter->index < list->size) {
    1.10 +        int result = cx_arl_insert(
    1.11 +                list,
    1.12 +                iter->index + 1 - prepend,
    1.13 +                elem
    1.14 +        );
    1.15 +        if (result == 0 && prepend != 0) {
    1.16 +            iter->index++;
    1.17 +            iter->elem_handle = ((char *) iter->elem_handle) + list->itemsize;
    1.18 +        }
    1.19 +        return result;
    1.20 +    } else {
    1.21 +        int result = cx_arl_add(list, elem);
    1.22 +        iter->index = list->size;
    1.23 +        return result;
    1.24 +    }
    1.25  }
    1.26  
    1.27  static int cx_arl_remove(

mercurial