stack: also update stack_size to return idx_t
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 5 Jan 2022 19:51:38 +0000 (11:51 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 5 Jan 2022 19:51:38 +0000 (11:51 -0800)
* lib/stack.h (_GL_STACK_PREFIX (size)): Return idx_t, not size_t.

ChangeLog
NEWS
lib/stack.h

index 609720a451ec85105a8603f0c11770291a8c3f09..4829d58e83d07c134a3749f8c5f1c630fb3ac409 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
        * lib/stack.h (_GL_STACK_TYPE): Use idx_t for size too.
        Suggested by Bruno Haible in:
        https://lists.gnu.org/r/bug-gnulib/2022-01/msg00035.html
+       (_GL_STACK_PREFIX (size)): Return idx_t, not size_t.
 
 2022-01-05  Bruno Haible  <bruno@clisp.org>
 
diff --git a/NEWS b/NEWS
index 2ce1c73014c000685975138e88c54aa77973fa39..c13a115adab72bed48b8762c311e40ce6a4c447b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,9 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2022-01-05  stack           This module now uses idx_t instead of size_t
+                            for indexes and counts.
+
 2021-08-27  base32          These modules now use idx_t instead of size_t
             base64          for indexes and counts.
 
index b4c35535a7dd5cdba2e8ba5de512e71439a8e25b..28b9d7a542ef08748cb15d396cdf2122d39867e1 100644 (file)
@@ -17,7 +17,7 @@
 /* Written by Marc Nieper-Wißkirchen <marc@nieper-wisskirchen.de>, 2020.  */
 
 /* This header file does not have include-guards as it is meant to be
-   includeable multiple times as long as the necessary defines have
+   includable multiple times as long as the necessary defines have
    been set up.
 
    A stack is implemented with a homogenous array of elements in
@@ -36,7 +36,7 @@
      Popping:            ELEMENT element = stack_pop (&stack);
      Discarding:         stack_discard (&stack);
      Top-of-stack:       ELEMENT element = stack_top (&stack);
-     Size:               size_t size = stack_size (&stack);
+     Size:               idx_t size = stack_size (&stack);
 
    Here, ELEMENT is the type to which GL_STACK_ELEMENT was defined when
    this file was included.
@@ -152,7 +152,7 @@ _GL_STACK_PREFIX (top) (const _GL_STACK_TYPE *stack)
 }
 
 /* Return the currently stored number of elements in the stack.  */
-GL_STACK_STORAGECLASS _GL_ATTRIBUTE_PURE size_t
+GL_STACK_STORAGECLASS _GL_ATTRIBUTE_PURE idx_t
 _GL_STACK_PREFIX (size) (const _GL_STACK_TYPE *stack)
 {
   return stack->size;