* lib/getusershell.c (line_size, readname):
* lib/linebuffer.c (readlinebuffer_delim):
* lib/linebuffer.h (struct linebuffer):
+ * lib/readtokens.c (readtoken, readtokens):
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.
size_t n_delim,
token_buffer *tokenbuffer)
{
- char *p;
int c;
- size_t i, n;
+ idx_t i;
word isdelim[(UCHAR_MAX + bits_per_word) / bits_per_word];
memset (isdelim, 0, sizeof isdelim);
/* empty */
}
- p = tokenbuffer->buffer;
- n = tokenbuffer->size;
+ char *p = tokenbuffer->buffer;
+ idx_t n = tokenbuffer->size;
i = 0;
for (;;)
{
return -1;
if (i == n)
- p = x2nrealloc (p, &n, sizeof *p);
+ p = xpalloc (p, &n, 1, -1, sizeof *p);
if (c < 0)
{
token_buffer tb, *token = &tb;
char **tokens;
size_t *lengths;
- size_t sz;
- size_t n_tokens;
+ idx_t sz, n_tokens;
if (projected_n_tokens == 0)
projected_n_tokens = 64;
size_t token_length = readtoken (stream, delim, n_delim, token);
if (n_tokens >= sz)
{
- tokens = x2nrealloc (tokens, &sz, sizeof *tokens);
+ tokens = xpalloc (tokens, &sz, 1, -1, sizeof *tokens);
lengths = xreallocarray (lengths, sz, sizeof *lengths);
}