--- a/docs/Writerside/topics/array_list.h.md Thu Dec 18 16:44:11 2025 +0100 +++ b/docs/Writerside/topics/array_list.h.md Thu Dec 18 18:07:29 2025 +0100 @@ -81,23 +81,23 @@ ```C #include <cx/array_list.h> -int cx_array_add(CxArray array, const void *element); +int cx_array_add(CxArray array, Any element); int cx_array_add_array(CxArray array, const void *other, size_t n); -int cx_array_insert(CxArray array, size_t index, const void *element); +int cx_array_insert(CxArray array, size_t index, Any element); int cx_array_insert_array(CxArray array, size_t index, const void *other, size_t n); int cx_array_add_a(const CxAllocator* allocator, - CxArray array, const void *element); + CxArray array, Any element); int cx_array_add_array(const CxAllocator* allocator, CxArray array, const void *other, size_t n); int cx_array_insert_a(const CxAllocator* allocator, - CxArray array, size_t index, const void *element); + CxArray array, size_t index, Any element); int cx_array_insert_array_a(const CxAllocator* allocator, CxArray array, size_t index, const void *other, size_t n); @@ -109,6 +109,10 @@ When the array capacity is not sufficient, a re-allocation is attempted. If the allocation fails, the function returns non-zero. +> Since the "functions" are actually macros, the variants which add or insert one single element +> also conveniently take the address of the passed argument, so you don't have to do it. +> This is why the type is specified as `Any` instead of `const void*` here. + > Be careful when using these functions on an array that was initialized with fixed-sized memory. > In this case, you MUST make sure that the capacity is sufficient or reallocate the array > with `cx_array_copy_to_new()` or `cx_array_copy_to_new_a()` before adding or inserting more elements. @@ -143,8 +147,7 @@ ```C #include <cx/array_list.h> -int cx_array_insert_sorted(CxArray array, - const void *element, +int cx_array_insert_sorted(CxArray array, Any element, cx_compare_func cmp_func); int cx_array_insert_sorted_array(CxArray array, @@ -152,15 +155,14 @@ cx_compare_func cmp_func); int cx_array_insert_sorted_a(const CxAllocator *allocator, - CxArray array, const void *element, + CxArray array, Any element, cx_compare_func cmp_func); int cx_array_insert_sorted_array_a(const CxAllocator *allocator, CxArray array, const void *sorted_data, size_t n, cx_compare_func cmp_func); -int cx_array_insert_sorted_c(CxArray array, - const void *element, +int cx_array_insert_sorted_c(CxArray array, Any element, cx_compare_func2 cmp_func, void *context); int cx_array_insert_sorted_array_c(CxArray array, @@ -168,7 +170,7 @@ cx_compare_func2 cmp_func, void *context); int cx_array_insert_sorted_ca(const CxAllocator *allocator, - CxArray array, const void *element, + CxArray array, Any element, cx_compare_func2 cmp_func, void *context); int cx_array_insert_sorted_array_ca(const CxAllocator *allocator, @@ -185,8 +187,7 @@ ```C #include <cx/array_list.h> -int cx_array_insert_unique(CxArray array, - const void *element, +int cx_array_insert_unique(CxArray array, Any element, cx_compare_func cmp_func); int cx_array_insert_unique_array(CxArray array, @@ -194,15 +195,14 @@ cx_compare_func cmp_func); int cx_array_insert_unique_a(const CxAllocator *allocator, - CxArray array, const void *element, + CxArray array, Any element, cx_compare_func cmp_func); int cx_array_insert_unique_array_a(const CxAllocator *allocator, CxArray array, const void *sorted_data, size_t n, cx_compare_func cmp_func); -int cx_array_insert_unique_c(CxArray array, - const void *element, +int cx_array_insert_unique_c(CxArray array, Any element, cx_compare_func2 cmp_func, void *context); int cx_array_insert_unique_array_c(CxArray array, @@ -210,7 +210,7 @@ cx_compare_func2 cmp_func, void *context); int cx_array_insert_unique_ca(const CxAllocator *allocator, - CxArray array, const void *element, + CxArray array, Any element, cx_compare_func2 cmp_func, void *context); int cx_array_insert_unique_array_ca(const CxAllocator *allocator,