util_string: dynamically allocate and expand string lists
String lists grow dynamically, removing the need for preallocated arrays. This simplifies handling of large variable groups in the icon initialization phase.
The output lists of add_to_list
are now ALLOCATABLE
. They may be passed an unallocated
argument, which is treated like an empty list and allocated using the new new_list
subroutine. That subroutine initially allocates space for 8 strings. Every time the list
needs to grow, the allocated size doubles. This ensures constant amortized runtime for
adding to the list. No provisions are made for shrinking the list size, because they are
usually short-lived.
The tests for add_to_list
are adapted for the new interface, checking list expansion.
A new test for new_list
is added.