Address emersion's feedback on peek_line

This commit is contained in:
Brian Ashworth 2018-06-01 18:35:16 -04:00
parent fbca3bbacb
commit af87c7a1af
2 changed files with 5 additions and 5 deletions

View file

@ -49,11 +49,11 @@ char *read_line(FILE *file) {
return string;
}
char *peek_line(FILE *file, int offset, long *position) {
char *peek_line(FILE *file, int line_offset, long *position) {
long pos = ftell(file);
size_t length = 1;
char *line = calloc(1, length);
for (int i = 0; i <= offset; i++) {
size_t length = 0;
char *line = NULL;
for (int i = 0; i <= line_offset; i++) {
ssize_t read = getline(&line, &length, file);
if (read < 0) {
break;

View file

@ -4,7 +4,7 @@
#include <stdio.h>
char *read_line(FILE *file);
char *peek_line(FILE *file, int offset, long *position);
char *peek_line(FILE *file, int line_offset, long *position);
char *read_line_buffer(FILE *file, char *string, size_t string_len);
#endif