Skip to content
Snippets Groups Projects
Commit 01786a99 authored by Roland Wirth's avatar Roland Wirth Committed by Yen-Chen Chen
Browse files

util_string: dynamically allocate and expand string lists (!88)


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.

Approved-by: default avatarYen-Chen Chen <yen-chen.chen@kit.edu>
Merged-by: default avatarYen-Chen Chen <yen-chen.chen@kit.edu>
Changelog: feature
parent 1651516a
No related branches found
No related tags found
1 merge request!88util_string: dynamically allocate and expand string lists
Pipeline #67429 passed