summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
485xs_list *index_list(const char *fn, int max) 485xs_list *index_list(const char *fn, int max)
486/* returns an index as a list */ 486/* returns an index as a list */
487{ 487{
488 xs_list *list = NULL; 488 xs_list *list = xs_list_new();
489 FILE *f; 489 FILE *f;
490 int n = 0; 490 int n = 0;
491 491
@@ -493,7 +493,6 @@ xs_list *index_list(const char *fn, int max)
493 flock(fileno(f), LOCK_SH); 493 flock(fileno(f), LOCK_SH);
494 494
495 char line[256]; 495 char line[256];
496 list = xs_list_new();
497 496
498 while (n < max && fgets(line, sizeof(line), f) != NULL) { 497 while (n < max && fgets(line, sizeof(line), f) != NULL) {
499 if (line[0] != '-') { 498 if (line[0] != '-') {
@@ -513,7 +512,7 @@ xs_list *index_list(const char *fn, int max)
513xs_list *index_list_desc(const char *fn, int skip, int show) 512xs_list *index_list_desc(const char *fn, int skip, int show)
514/* returns an index as a list, in reverse order */ 513/* returns an index as a list, in reverse order */
515{ 514{
516 xs_list *list = NULL; 515 xs_list *list = xs_list_new();
517 FILE *f; 516 FILE *f;
518 int n = 0; 517 int n = 0;
519 518
@@ -521,7 +520,6 @@ xs_list *index_list_desc(const char *fn, int skip, int show)
521 flock(fileno(f), LOCK_SH); 520 flock(fileno(f), LOCK_SH);
522 521
523 char line[256]; 522 char line[256];
524 list = xs_list_new();
525 523
526 /* move to the end minus one entry (or more, if skipping entries) */ 524 /* move to the end minus one entry (or more, if skipping entries) */
527 if (!fseek(f, 0, SEEK_END) && !fseek(f, (skip + 1) * -33, SEEK_CUR)) { 525 if (!fseek(f, 0, SEEK_END) && !fseek(f, (skip + 1) * -33, SEEK_CUR)) {