From f836b1a9e27f7bc74ef53332ac10fd88375742dd Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Thu, 14 Apr 2022 16:48:32 +0800 Subject: [PATCH] bugfixed: fc_get_file_line_count_ex should rewind file --- src/shared_func.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared_func.c b/src/shared_func.c index 0962382..35a1e30 100644 --- a/src/shared_func.c +++ b/src/shared_func.c @@ -748,7 +748,9 @@ int fc_get_file_line_count_ex(const char *filename, remain_bytes = until_offset; } else { remain_bytes = lseek(fd, 0, SEEK_END); + lseek(fd, 0, SEEK_SET); } + while (remain_bytes > 0) { read_bytes = remain_bytes >= READ_BUFFER_SIZE ? (READ_BUFFER_SIZE - 1) : remain_bytes; @@ -3527,7 +3529,6 @@ int64_t fc_ceil_prime(const int64_t n) } int fc_init_buffer(BufferInfo *buffer, const int buffer_size) - { buffer->buff = (char *)fc_malloc(buffer_size); if (buffer->buff == NULL)