# HG changeset patch
# User Mike Becker <universe@uap-core.de>
# Date 1706131145 -3600
# Node ID 949908c97474e29e8939071c433dade3e4ef0b7e
# Parent  425234b05dff40f392bfb093aa645e58611bf584
add cx_array_default_reallocator

diff -r 425234b05dff -r 949908c97474 CHANGELOG
--- a/CHANGELOG	Mon Jan 22 19:34:38 2024 +0100
+++ b/CHANGELOG	Wed Jan 24 22:19:05 2024 +0100
@@ -1,5 +1,7 @@
 Version 3.1 - tbd.
 ------------------------
+ * adds tree.h
+ * adds cx_array_default_reallocator
  * adds cx_linked_list_find_node()
  * adds cxListFindRemove()
  * adds cxBufferReset()
diff -r 425234b05dff -r 949908c97474 src/array_list.c
--- a/src/array_list.c	Mon Jan 22 19:34:38 2024 +0100
+++ b/src/array_list.c	Wed Jan 24 22:19:05 2024 +0100
@@ -31,6 +31,21 @@
 #include <assert.h>
 #include <string.h>
 
+// Default array reallocator
+
+static void *cx_array_default_realloc(
+        void *array,
+        size_t capacity,
+        size_t elem_size,
+        __attribute__((__unused__)) struct cx_array_reallocator_s *alloc
+) {
+    return realloc(array, capacity * elem_size);
+}
+
+struct cx_array_reallocator_s cx_array_default_reallocator = {
+        cx_array_default_realloc, NULL, NULL, 0, 0
+};
+
 // LOW LEVEL ARRAY LIST FUNCTIONS
 
 enum cx_array_copy_result cx_array_copy(
diff -r 425234b05dff -r 949908c97474 src/cx/array_list.h
--- a/src/cx/array_list.h	Mon Jan 22 19:34:38 2024 +0100
+++ b/src/cx/array_list.h	Wed Jan 24 22:19:05 2024 +0100
@@ -94,6 +94,11 @@
 };
 
 /**
+ * A default stdlib-based array reallocator.
+ */
+extern struct cx_array_reallocator_s cx_array_default_reallocator;
+
+/**
  * Return codes for cx_array_copy().
  */
 enum cx_array_copy_result {