]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
exclude: Use the counted_by attribute.
authorBruno Haible <bruno@clisp.org>
Sun, 3 May 2026 08:52:33 +0000 (10:52 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 3 May 2026 13:34:21 +0000 (15:34 +0200)
* lib/exclude.c (struct exclude_pattern): Mark the exclude field as
counted_by exclude_count. Swap these fields (needed for clang, see
<https://discourse.llvm.org/t/rfc-forward-referencing-a-struct-member-within-bounds-annotations/85510>).
(new_exclude_segment): Update.
(add_exclude): Increase pat->exclude_count before writing into
pat->exclude.

ChangeLog
lib/exclude.c

index a228019e0a9d90a35d66d38da926e010bff31370..e3d0de73cfafa2a4e7345b306c9fab7b39ac6a6a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-05-03  Bruno Haible  <bruno@clisp.org>
+
+       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
+       <https://discourse.llvm.org/t/rfc-forward-referencing-a-struct-member-within-bounds-annotations/85510>).
+       (new_exclude_segment): Update.
+       (add_exclude): Increase pat->exclude_count before writing into
+       pat->exclude.
+
 2026-05-03  Bruno Haible  <bruno@clisp.org>
 
        dfa: Use the counted_by attribute.
index 8cf4103c118b280503e9795f826d7dc4f7dad355..6a8604ec1baeaca50af27da3998ad4d9d7a4c2aa 100644 (file)
@@ -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)