trailer: separate public from internal portion of trailer_iterator

The fields here are not meant to be used by downstream callers, so put
them behind an anonymous struct named as "internal" to warn against
their use. This follows the pattern in 576de3d956 (unpack_trees: start
splitting internal fields from public API, 2023-02-27).

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Linus Arver 2023-09-09 06:16:12 +00:00 committed by Junio C Hamano
parent ac83bc5054
commit 13211ae23f
2 changed files with 9 additions and 7 deletions

View File

@ -1220,14 +1220,14 @@ void trailer_iterator_init(struct trailer_iterator *iter, const char *msg)
strbuf_init(&iter->key, 0);
strbuf_init(&iter->val, 0);
opts.no_divider = 1;
trailer_info_get(&iter->info, msg, &opts);
iter->cur = 0;
trailer_info_get(&iter->internal.info, msg, &opts);
iter->internal.cur = 0;
}
int trailer_iterator_advance(struct trailer_iterator *iter)
{
while (iter->cur < iter->info.trailer_nr) {
char *trailer = iter->info.trailers[iter->cur++];
while (iter->internal.cur < iter->internal.info.trailer_nr) {
char *trailer = iter->internal.info.trailers[iter->internal.cur++];
int separator_pos = find_separator(trailer, separators);
if (separator_pos < 1)
@ -1245,7 +1245,7 @@ int trailer_iterator_advance(struct trailer_iterator *iter)
void trailer_iterator_release(struct trailer_iterator *iter)
{
trailer_info_release(&iter->info);
trailer_info_release(&iter->internal.info);
strbuf_release(&iter->val);
strbuf_release(&iter->key);
}

View File

@ -119,8 +119,10 @@ struct trailer_iterator {
struct strbuf val;
/* private */
struct trailer_info info;
size_t cur;
struct {
struct trailer_info info;
size_t cur;
} internal;
};
/*