From: Bruno Haible Date: Sun, 3 May 2026 08:52:33 +0000 (+0200) Subject: exclude: Use the counted_by attribute. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46e36ea9b1bbfa2fabac09cba113b8751576c535;p=thirdparty%2Fgnulib.git exclude: Use the counted_by attribute. * lib/exclude.c (struct exclude_pattern): Mark the exclude field as counted_by exclude_count. Swap these fields (needed for clang, see ). (new_exclude_segment): Update. (add_exclude): Increase pat->exclude_count before writing into pat->exclude. --- diff --git a/ChangeLog b/ChangeLog index a228019e0a..e3d0de73cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2026-05-03 Bruno Haible + + exclude: Use the counted_by attribute. + * lib/exclude.c (struct exclude_pattern): Mark the exclude field as + counted_by exclude_count. Swap these fields (needed for clang, see + ). + (new_exclude_segment): Update. + (add_exclude): Increase pat->exclude_count before writing into + pat->exclude. + 2026-05-03 Bruno Haible dfa: Use the counted_by attribute. diff --git a/lib/exclude.c b/lib/exclude.c index 8cf4103c11..6a8604ec1b 100644 --- a/lib/exclude.c +++ b/lib/exclude.c @@ -89,9 +89,10 @@ struct patopts struct exclude_pattern { - struct patopts *exclude; - idx_t exclude_alloc; idx_t exclude_count; + struct patopts *exclude + _GL_ATTRIBUTE_COUNTED_BY (exclude_count); + idx_t exclude_alloc; }; enum exclude_type @@ -261,7 +262,7 @@ new_exclude_segment (struct exclude *ex, enum exclude_type type, int options) switch (type) { case exclude_pattern: - sp->v.pat = (struct exclude_pattern) { NULL, 0, 0 }; + sp->v.pat = (struct exclude_pattern) { 0, NULL, 0 }; break; case exclude_hash: @@ -519,7 +520,8 @@ add_exclude (struct exclude *ex, char const *pattern, int options) if (pat->exclude_count == pat->exclude_alloc) pat->exclude = xpalloc (pat->exclude, &pat->exclude_alloc, 1, -1, sizeof *pat->exclude); - struct patopts *patopts = &pat->exclude[pat->exclude_count++]; + idx_t pat_index = pat->exclude_count++; + struct patopts *patopts = &pat->exclude[pat_index]; patopts->options = options; if (options & EXCLUDE_REGEX)