no need to track tableBuf

free() is compatible with NULL,
let's free() unconditionnally
This commit is contained in:
Yann Collet
2019-10-25 17:34:29 -07:00
parent 8e414b586d
commit 5fb84ca2cf
3 changed files with 22 additions and 31 deletions
+4 -5
View File
@@ -200,17 +200,16 @@ U64 UTIL_getFileSize(const char* infilename)
}
U64 UTIL_getTotalFileSize(const char* const * const fileNamesTable, unsigned nbFiles)
U64 UTIL_getTotalFileSize(const char* const * fileNamesTable, unsigned nbFiles)
{
U64 total = 0;
int error = 0;
unsigned n;
for (n=0; n<nbFiles; n++) {
U64 const size = UTIL_getFileSize(fileNamesTable[n]);
error |= (size == UTIL_FILESIZE_UNKNOWN);
if (size == UTIL_FILESIZE_UNKNOWN) return UTIL_FILESIZE_UNKNOWN;
total += size;
}
return error ? UTIL_FILESIZE_UNKNOWN : total;
return total;
}
@@ -222,7 +221,7 @@ static size_t readLineFromFile(char* buf, size_t len, FILE* file)
assert(!feof(file));
CONTROL( fgets(buf, (int) len, file) == buf ); /* requires success */
if (strlen(buf)==0) return 0;
return strlen(buf) - (buf[strlen(buf)-1] == '\n'); /* -1 to ignore final '\n' character */
return strlen(buf) - (buf[strlen(buf)-1] == '\n'); /* ignore final '\n' character */
}
/* Conditions :