From: Paul Eggert <eggert@cs.ucla.edu>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [PATCH 11/13] stack: prefer idx_t for indexes
Date: Fri, 11 Jun 2021 17:25:51 -0700 [thread overview]
Message-ID: <20210612002553.1105537-11-eggert@cs.ucla.edu> (raw)
In-Reply-To: <20210612002553.1105537-1-eggert@cs.ucla.edu>
* lib/stack.h (_GL_STACK_TYPE, _GL_STACK_PREFIX):
Prefer idx_t to size_t for indexes, using idx_t-related allocators.
---
ChangeLog | 1 +
lib/stack.h | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 93039a69a..fc3c91d63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@
* lib/readtokens.c (readtoken, readtokens):
* lib/readutmp.c (read_utmp):
* lib/savedir.c (streamsavedir):
+ * lib/stack.h (_GL_STACK_TYPE, _GL_STACK_PREFIX):
Prefer idx_t to size_t for indexes, and use idx_t-related allocators.
* lib/basename.c: Do not include xstrndup.h.
(basename): Simplify by always using memcpy.
diff --git a/lib/stack.h b/lib/stack.h
index dfd57501f..9c3afe724 100644
--- a/lib/stack.h
+++ b/lib/stack.h
@@ -78,7 +78,7 @@ typedef struct
{
GL_STACK_ELEMENT *base;
size_t size;
- size_t allocated;
+ idx_t allocated;
} _GL_STACK_TYPE;
/* Initialize a stack. */
@@ -119,8 +119,8 @@ GL_STACK_STORAGECLASS void
_GL_STACK_PREFIX (push) (_GL_STACK_TYPE *stack, GL_STACK_ELEMENT item)
{
if (stack->size == stack->allocated)
- stack->base = x2nrealloc (stack->base, &stack->allocated,
- sizeof (GL_STACK_ELEMENT));
+ stack->base = xpalloc (stack->base, &stack->allocated, 1, -1,
+ sizeof *stack->base);;
stack->base [stack->size++] = item;
}
--
2.30.2
next prev parent reply other threads:[~2021-06-12 0:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-12 0:25 [PATCH 01/13] ialloc: new module Paul Eggert
2021-06-12 0:25 ` [PATCH 02/13] xalloc: new idx_t-based allocators Paul Eggert
2021-06-12 0:25 ` [PATCH 03/13] dirname: prefer idx_t for some indexes Paul Eggert
2021-06-12 0:25 ` [PATCH 04/13] dfa: prefer idx_t for indexes Paul Eggert
2021-06-12 0:25 ` [PATCH 05/13] exclude: prefer idx_t for most indexes Paul Eggert
2021-06-12 0:25 ` [PATCH 06/13] getusershell: prefer idx_t for indexes Paul Eggert
2021-06-12 0:25 ` [PATCH 07/13] linebuffer: " Paul Eggert
2021-06-12 0:25 ` [PATCH 08/13] readtokens: " Paul Eggert
2021-06-12 0:25 ` [PATCH 09/13] readutmp: " Paul Eggert
2021-06-12 0:25 ` [PATCH 10/13] savedir: " Paul Eggert
2021-06-12 0:25 ` Paul Eggert [this message]
2021-06-13 10:19 ` [PATCH 11/13] stack: " Bruno Haible
2021-06-13 17:47 ` Paul Eggert
2021-06-12 0:25 ` [PATCH 12/13] userspec: " Paul Eggert
2021-06-12 0:25 ` [PATCH 13/13] xgethostname: " Paul Eggert
2021-06-13 10:05 ` [PATCH 01/13] ialloc: new module Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210612002553.1105537-11-eggert@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).