From 9d47a1d50ba2a84b76a0edbbc94fe741e196795d Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sun, 10 Mar 2024 14:14:02 +0300 Subject: [PATCH] freadln.c: improve function I/O logic --- c-programming/io/freadln.c | 2 +- c-programming/io/freadln.h | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/c-programming/io/freadln.c b/c-programming/io/freadln.c index b9a6d5f..56b7579 100644 --- a/c-programming/io/freadln.c +++ b/c-programming/io/freadln.c @@ -16,7 +16,7 @@ #include "freadln.h" -ssize_t freadln(char** output, size_t* length_out) { +int freadln(char** output, size_t* length_out) { /* * The length of STDIN line is counted without any terminating characters. * diff --git a/c-programming/io/freadln.h b/c-programming/io/freadln.h index 8680dc2..0026352 100644 --- a/c-programming/io/freadln.h +++ b/c-programming/io/freadln.h @@ -21,14 +21,11 @@ enum freadln_status { #define freadln_success_epilogue do { \ (*output)[length] = '\0'; \ - if (length_out == NULL) \ - return length; \ - else { \ + if (length_out != NULL) \ *length_out = length; \ - return freadln_OK; \ - } \ + return freadln_OK; \ } while (0) -ssize_t freadln(char** output, size_t* length_out); +int freadln(char** output, size_t* length_out); #endif /* _FREADLN_H */