add some asserts

Thu, 23 Feb 2023 22:24:26 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 23 Feb 2023 22:24:26 +0100
changeset 660
4738a9065907
parent 659
4a06fd63909a
child 661
0a71ac9547fd

add some asserts

src/array_list.c file | annotate | diff | comparison | revisions
     1.1 --- a/src/array_list.c	Thu Feb 23 21:42:46 2023 +0100
     1.2 +++ b/src/array_list.c	Thu Feb 23 22:24:26 2023 +0100
     1.3 @@ -112,6 +112,8 @@
     1.4          size_t idx1,
     1.5          size_t idx2
     1.6  ) {
     1.7 +    assert(arr != NULL);
     1.8 +
     1.9      // short circuit
    1.10      if (idx1 == idx2) return;
    1.11  
    1.12 @@ -319,6 +321,7 @@
    1.13          struct cx_list_s const *list,
    1.14          void const *elem
    1.15  ) {
    1.16 +    assert(list->cmpfunc != NULL);
    1.17      char *cur = ((cx_array_list const *) list)->data;
    1.18  
    1.19      for (size_t i = 0; i < list->size; i++) {
    1.20 @@ -332,6 +335,7 @@
    1.21  }
    1.22  
    1.23  static void cx_arl_sort(struct cx_list_s *list) {
    1.24 +    assert(list->cmpfunc != NULL);
    1.25      qsort(((cx_array_list *) list)->data,
    1.26            list->size,
    1.27            list->itemsize,
    1.28 @@ -343,6 +347,7 @@
    1.29          struct cx_list_s const *list,
    1.30          struct cx_list_s const *other
    1.31  ) {
    1.32 +    assert(list->cmpfunc != NULL);
    1.33      if (list->size == other->size) {
    1.34          char const *left = ((cx_array_list const *) list)->data;
    1.35          char const *right = ((cx_array_list const *) other)->data;

mercurial