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
--- a/src/array_list.c	Thu Feb 23 21:42:46 2023 +0100
+++ b/src/array_list.c	Thu Feb 23 22:24:26 2023 +0100
@@ -112,6 +112,8 @@
         size_t idx1,
         size_t idx2
 ) {
+    assert(arr != NULL);
+
     // short circuit
     if (idx1 == idx2) return;
 
@@ -319,6 +321,7 @@
         struct cx_list_s const *list,
         void const *elem
 ) {
+    assert(list->cmpfunc != NULL);
     char *cur = ((cx_array_list const *) list)->data;
 
     for (size_t i = 0; i < list->size; i++) {
@@ -332,6 +335,7 @@
 }
 
 static void cx_arl_sort(struct cx_list_s *list) {
+    assert(list->cmpfunc != NULL);
     qsort(((cx_array_list *) list)->data,
           list->size,
           list->itemsize,
@@ -343,6 +347,7 @@
         struct cx_list_s const *list,
         struct cx_list_s const *other
 ) {
+    assert(list->cmpfunc != NULL);
     if (list->size == other->size) {
         char const *left = ((cx_array_list const *) list)->data;
         char const *right = ((cx_array_list const *) other)->data;

mercurial