improve: companion.c, dl.c and utils.c code

This commit improves the code for multiple files by making "read_string" function already make the string NULL-terminated, avoiding code duplication. Also for "companion.c" fixes an "if" where it would read "client_fd" and check if "fd" is equal to "-1", instead of "client_fd", also does some overall code improvements there like detaching the thread, avoiding memory leaks in the exit, of the thread itself.
This commit is contained in:
ThePedroo
2024-12-22 14:57:39 -03:00
parent 6b0b71a690
commit 7a892e0d62
5 changed files with 59 additions and 67 deletions

View File

@@ -91,7 +91,7 @@ read_func_def(uint8_t);
ssize_t write_string(int fd, const char *restrict str);
ssize_t read_string(int fd, char *restrict str, size_t len);
ssize_t read_string(int fd, char *restrict buf, size_t buf_size);
bool exec_command(char *restrict buf, size_t len, const char *restrict file, char *const argv[]);