* lib/linebuffer.c (readlinebuffer_delim):
* lib/linebuffer.h (struct linebuffer):
* lib/readtokens.c (readtoken, readtokens):
+ * lib/readutmp.c (read_utmp):
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.
read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf,
int options)
{
- size_t n_read = 0;
- size_t n_alloc = 0;
+ idx_t n_read = 0;
+ idx_t n_alloc = 0;
STRUCT_UTMP *utmp = NULL;
STRUCT_UTMP *u;
if (desirable_utmp_entry (u, options))
{
if (n_read == n_alloc)
- utmp = x2nrealloc (utmp, &n_alloc, sizeof *utmp);
+ utmp = xpalloc (utmp, &n_alloc, 1, -1, sizeof *utmp);
utmp[n_read++] = *u;
}
read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf,
int options)
{
- size_t n_read = 0;
- size_t n_alloc = 0;
+ idx_t n_read = 0;
+ idx_t n_alloc = 0;
STRUCT_UTMP *utmp = NULL;
int saved_errno;
FILE *f = fopen (file, "re");
for (;;)
{
if (n_read == n_alloc)
- utmp = x2nrealloc (utmp, &n_alloc, sizeof *utmp);
+ utmp = xpalloc (utmp, &n_alloc, 1, -1, sizeof *utmp);
if (fread (&utmp[n_read], sizeof utmp[n_read], 1, f) == 0)
break;
n_read += desirable_utmp_entry (&utmp[n_read], options);
};
char *extract_trimmed_name (const STRUCT_UTMP *ut);
+
+/* FIXME: This header should use idx_t, not size_t. */
int read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf,
int options);