]> Savannah Git Hosting - gnulib.git/commitdiff
getusershell: prefer idx_t for indexes
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 12 Jun 2021 00:20:12 +0000 (17:20 -0700)
* lib/getusershell.c (line_size, readname):
Prefer idx_t to size_t for indexes, using idx_t-related allocators.

ChangeLog
lib/getusershell.c

index 1fca94c036567cf26dc817a5321a8269cbbf505b..84ccb3645187a6667556056a631d3bc3dcdf603d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
        (icatalloc, enlist, allocmust, dfamust):
        * lib/exclude.c (struct exclude_pattern, free_exclude_segment)
        (file_pattern_matches, add_exclude, add_exclude_fp):
+       * lib/getusershell.c (line_size, readname):
        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.
index be8a068455e6c3dbb1bc2328e69eb0f6711fabe0..32acd76c06d2c579cdcb768f50e3c9c30bfbaa12 100644 (file)
@@ -43,7 +43,7 @@
 # include "unlocked-io.h"
 #endif
 
-static size_t readname (char **, size_t *, FILE *);
+static idx_t readname (char **, idx_t *, FILE *);
 
 #if ! defined ADDITIONAL_DEFAULT_SHELLS && defined __MSDOS__
 # define ADDITIONAL_DEFAULT_SHELLS \
@@ -70,7 +70,7 @@ static FILE *shellstream = NULL;
 static char *line = NULL;
 
 /* Number of bytes allocated for 'line'. */
-static size_t line_size = 0;
+static idx_t line_size = 0;
 \f
 /* Return an entry from the shells file, ignoring comment lines.
    If the file doesn't exist, use the list in DEFAULT_SHELLS (above).
@@ -137,8 +137,8 @@ endusershell (void)
    Return the number of bytes placed in *NAME
    if some nonempty sequence was found, otherwise 0.  */
 
-static size_t
-readname (char **name, size_t *size, FILE *stream)
+static idx_t
+readname (char **name, idx_t *size, FILE *stream)
 {
   int c;
   size_t name_index = 0;
@@ -150,7 +150,7 @@ readname (char **name, size_t *size, FILE *stream)
   for (;;)
     {
       if (*size <= name_index)
-        *name = x2nrealloc (*name, size, sizeof **name);
+        *name = xpalloc (*name, size, 1, -1, sizeof **name);
       if (c == EOF || isspace (c))
         break;
       (*name)[name_index++] = c;