fix for empty arrays

Tue, 17 Sep 2024 23:37:15 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 17 Sep 2024 23:37:15 +0200
changeset 888
6f44b1f1275c
parent 887
e5181fe13b9c
child 889
f549fd9fbd8f

fix for empty arrays

relates to #424

src/array_list.c file | annotate | diff | comparison | revisions
--- a/src/array_list.c	Tue Sep 17 23:32:27 2024 +0200
+++ b/src/array_list.c	Tue Sep 17 23:37:15 2024 +0200
@@ -243,6 +243,9 @@
         void const *elem,
         cx_compare_func cmp_func
 ) {
+    // special case: empty array
+    if (size == 0) return 0;
+
     // declare a variable that will contain the compare results
     int result;
 

mercurial