[PATCH v2 3/6] reflog-walk.c: use string_list_init_dup()
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jul 21, 2022, 12:00 UTC
- Message-ID
- <patch-v2-3.6-62aab32ae77-20220721T111808Z-avarab@gmail.com>
- In-Reply-To
- <cover-v2-0.6-00000000000-20220721T111808Z-avarab@gmail.com>
Change init_reflog_walk() to use the helper function added in 183113a5ca9 (string_list: Add STRING_LIST_INIT macro and make use of it., 2010-07-04) rather than assuming that the "struct string_list" part of "struct reflog_walk_info" can be memset() to 0, followed by flipping ".strdup_strings = 1".
As explained in a preceding commit that can be assumed now if we peek behind the guts of the "struct string_list", but there's no reason to break the encapsulation here.
This does not match the newly added "struct string_list" rule for changing CALLOC_ARRAY() followed by ".strdup_strings = 1" to "ALLOC_ARRAY()" and "string_list_init_dup()" because here the "CALLOC_ARRAY()" is allocating more than just the "struct string_list".
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- reflog-walk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/reflog-walk.c b/reflog-walk.c index 7aa6595a51f..2b17408f9a4 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -120,7 +120,7 @@ struct reflog_walk_info { void init_reflog_walk(struct reflog_walk_info **info) { CALLOC_ARRAY(*info, 1); - (*info)->complete_reflogs.strdup_strings = 1; + string_list_init_dup(&((*info)->complete_reflogs)); } void reflog_walk_info_release(struct reflog_walk_info *info)
-- 2.37.1.1095.g64a1e8362fd