summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-07-05 14:41:47 +0200
committerdefault <nobody@localhost>2023-07-05 14:41:47 +0200
commite2789cece562d7351d5beb06c059a19d66a6716a (patch)
tree4a7a6c44a4e93dd27666fb14bb6d7e1d384e9c58
parent08e474561e0a844ad63c047aef2dd347b4fe0cc9 (diff)
index_list() and index_list_desc() always return a list, even if empty.
-rw-r--r--data.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/data.c b/data.c
index a221e82..1d6bfd1 100644
--- a/data.c
+++ b/data.c
@@ -485,7 +485,7 @@ int index_len(const char *fn)
xs_list *index_list(const char *fn, int max)
/* returns an index as a list */
{
- xs_list *list = NULL;
+ xs_list *list = xs_list_new();
FILE *f;
int n = 0;
@@ -493,7 +493,6 @@ xs_list *index_list(const char *fn, int max)
flock(fileno(f), LOCK_SH);
char line[256];
- list = xs_list_new();
while (n < max && fgets(line, sizeof(line), f) != NULL) {
if (line[0] != '-') {
@@ -513,7 +512,7 @@ xs_list *index_list(const char *fn, int max)
xs_list *index_list_desc(const char *fn, int skip, int show)
/* returns an index as a list, in reverse order */
{
- xs_list *list = NULL;
+ xs_list *list = xs_list_new();
FILE *f;
int n = 0;
@@ -521,7 +520,6 @@ xs_list *index_list_desc(const char *fn, int skip, int show)
flock(fileno(f), LOCK_SH);
char line[256];
- list = xs_list_new();
/* move to the end minus one entry (or more, if skipping entries) */
if (!fseek(f, 0, SEEK_END) && !fseek(f, (skip + 1) * -33, SEEK_CUR)) {