diff -r dc53362bc5a7 -r 581ad4fd01e9 src/cx/array_list.h --- a/src/cx/array_list.h Tue Oct 29 16:53:00 2024 +0100 +++ b/src/cx/array_list.h Tue Oct 29 18:14:02 2024 +0100 @@ -120,11 +120,36 @@ }; /** + * Typedef for the array reallocator struct. + */ +typedef struct cx_array_reallocator_s CxArrayReallocator; + +/** * A default stdlib-based array reallocator. */ extern struct cx_array_reallocator_s *cx_array_default_reallocator; /** + * Creates a new array reallocator. + * + * When \p allocator is \c NULL, the stdlib default allocator will be used. + * + * When \p stackmem is not \c NULL, the reallocator is supposed to be used + * \em only for the specific array that is initially located at \p stackmem. + * When reallocation is needed, the reallocator checks, if the array is + * still located at \p stackmem and copies the contents to the heap. + * + * @param allocator the allocator this reallocator shall be based on + * @param stackmem the address of the array when the array is initially located + * on the stack + * @return an array reallocator + */ +struct cx_array_reallocator_s cx_array_reallocator( + const struct cx_allocator_s *allocator, + const void *stackmem +); + +/** * Return codes for array functions. */ enum cx_array_result {