diff options
author | Oskar <[email protected]> | 2023-12-11 21:51:48 +0100 |
---|---|---|
committer | Oskar <[email protected]> | 2023-12-11 21:51:48 +0100 |
commit | 754f7875bec4bf60d7bb8c23a588c32de255d038 (patch) | |
tree | 72a7f77d62fba365366c27481ec69ced75fa106e /functions.c | |
parent | 5f973bc0b3a0d1ddbb33cc83c74ad6fa39688a9a (diff) |
Fixed some memory leaks... I think.
Diffstat (limited to 'functions.c')
-rw-r--r-- | functions.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/functions.c b/functions.c index 0d7c500..c114efd 100644 --- a/functions.c +++ b/functions.c @@ -133,17 +133,6 @@ int GET_LINE(char filename[], long focus, char **line, size_t *start) { // Makin return 1; } - /* - size_t lines; - int ret = COUNT_LINES_IN_FILE(filename, &lines); - if (ret == 1) { - return EXIT_FAILURE; - } - - if ((long)lines < focus) { // check if focus is bigger than the amount of - return EXIT_FAILURE; // lines in the actual file and returns exit failure - } - */ if (focus == 1) { int c1_count = 0; while (1) { @@ -172,7 +161,8 @@ int GET_LINE(char filename[], long focus, char **line, size_t *start) { // Makin strcpy(*line, c1buf); // Return line 1 } - *start = 0; + *start = 0; // Is start the start of where line + //printf("%s", c1buf); // The purpose of this if statement is that it will only print line 1. Not too elegant of a way to handle this but its the only way i knew how to. } else { @@ -219,9 +209,10 @@ int GET_LINE(char filename[], long focus, char **line, size_t *start) { // Makin if (*line != NULL) { strcpy(*line, c2buf); } - *start = save_i+1; + *start = save_i+1; // not sure but i think it saves the start position of the line + } fclose(file); return 0; -} +}
\ No newline at end of file |