diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 6 |
1 files changed, 2 insertions, 4 deletions
| @@ -485,7 +485,7 @@ int index_len(const char *fn) | |||
| 485 | xs_list *index_list(const char *fn, int max) | 485 | xs_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) | |||
| 513 | xs_list *index_list_desc(const char *fn, int skip, int show) | 512 | xs_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)) { |