]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/configs: merge new_list_entry() and configs_add_filename()
authorKarel Zak <kzak@redhat.com>
Wed, 15 Oct 2025 12:59:44 +0000 (14:59 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 15 Oct 2025 12:59:44 +0000 (14:59 +0200)
commitc8a753137f654d2b0a3c4b194e388f9f0f844f56
treeaeaa4f668ed3c57b0a0ec64c0f0f7829c2c4dfa9
parent9ff054b2d3253d43bc50082e1fa979e92d91d702
lib/configs: merge new_list_entry() and configs_add_filename()

Introduce configs_refer_filename() which merges the functionality
of new_list_entry() and configs_add_filename() while avoiding
unnecessary string duplication.

The new function takes ownership of the filename pointer directly
instead of using strdup(), which eliminates one allocation per
config file entry. Callers no longer need to free the filename
after adding it to the list, as ownership is transferred to the
list element.

This improves both performance and code clarity by making the
ownership semantics explicit.

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/configs.c