From a9dd71ffaca74346d5e3b8789a0da769ca0d890a Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 12 Jul 2025 11:13:22 -0400 Subject: Refactor usage of linebuffer to avoid using internal _num_words --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index ffa5ab4..45f9133 100644 --- a/src/main.c +++ b/src/main.c @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) { int justify(size_t linebuffer_capacity, FILE *in, FILE *out) { const size_t MAX_WORD_LENGTH = linebuffer_capacity; - char word[MAX_WORD_LENGTH + 2]; + char word[MAX_WORD_LENGTH + 1]; size_t word_length; int read_word_result; LineBuffer *lb = linebuffer_create(linebuffer_capacity); @@ -72,7 +72,7 @@ int justify(size_t linebuffer_capacity, FILE *in, FILE *out) { fprintf(stderr, "Error reading word\n"); return EXIT_FAILURE; } - if (lb->_num_words > 0) { + if (linebuffer_space_remaining(lb) < linebuffer_capacity) { linebuffer_write(lb, out); } linebuffer_destroy(lb); -- cgit v1.2.3