sway

i3-compatible Wayland compositor
git clone https://git.awy.one/sway
Log | Files | Refs | README | LICENSE

commit af87c7a1af8d790b819afe782fcff2830e959d58
parent fbca3bbacbe6e223a5e15d8265301b7d2c36af4e
Author: Brian Ashworth <bosrsf04@gmail.com>
Date:   Fri,  1 Jun 2018 18:35:16 -0400

Address emersion's feedback on peek_line

Diffstat:
Mcommon/readline.c | 8++++----
Minclude/readline.h | 2+-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/readline.c b/common/readline.c @@ -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; diff --git a/include/readline.h b/include/readline.h @@ -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