Addressed comments on malloc
This commit is contained in:
parent
c763457e0a
commit
4dc604cab8
@ -1453,9 +1453,6 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs, const char** inFileN
|
|||||||
} }
|
} }
|
||||||
|
|
||||||
FIO_freeCResources(ress);
|
FIO_freeCResources(ress);
|
||||||
if (dstFileNamesTable)
|
|
||||||
UTIL_freeDestinationFilenameTable(dstFileNamesTable, nbFiles);
|
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2276,9 +2273,6 @@ FIO_decompressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
FIO_freeDResources(ress);
|
FIO_freeDResources(ress);
|
||||||
if (outDirName)
|
|
||||||
UTIL_freeDestinationFilenameTable(dstFileNamesTable, nbFiles);
|
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,14 +140,22 @@ void UTIL_createDestinationDirTable(char** dstFilenameTable, const char** filena
|
|||||||
filenameBegin = strrchr(filenameTable[u], c[0]);
|
filenameBegin = strrchr(filenameTable[u], c[0]);
|
||||||
if (filenameBegin == NULL) {
|
if (filenameBegin == NULL) {
|
||||||
filename = (char*) malloc((strlen(filenameTable[u])+1) * sizeof(char));
|
filename = (char*) malloc((strlen(filenameTable[u])+1) * sizeof(char));
|
||||||
|
if (!filename) {
|
||||||
|
UTIL_DISPLAYLEVEL(1, "Unable to allocate space for filename str\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
strcpy(filename, filenameTable[u]);
|
strcpy(filename, filenameTable[u]);
|
||||||
} else {
|
} else {
|
||||||
filename = (char*) malloc((strlen(filenameBegin+1)) * sizeof(char));
|
filename = (char*) malloc((strlen(filenameBegin+1)+1) * sizeof(char));
|
||||||
|
if (!filename) {
|
||||||
|
UTIL_DISPLAYLEVEL(1, "Unable to allocate space for filename str\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
strcpy(filename, filenameBegin+1);
|
strcpy(filename, filenameBegin+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalPathLen += strlen(filename);
|
finalPathLen += strlen(filename);
|
||||||
dstFilenameTable[u] = (char*) malloc((finalPathLen+2) * sizeof(char));
|
dstFilenameTable[u] = (char*) malloc((finalPathLen+3) * sizeof(char));
|
||||||
if (!dstFilenameTable[u]) {
|
if (!dstFilenameTable[u]) {
|
||||||
UTIL_DISPLAYLEVEL(1, "Unable to allocate space for file destination str\n");
|
UTIL_DISPLAYLEVEL(1, "Unable to allocate space for file destination str\n");
|
||||||
free(filename);
|
free(filename);
|
||||||
|
@ -1192,6 +1192,9 @@ int main(int argCount, const char* argv[])
|
|||||||
operationResult = FIO_compressFilename(prefs, outFileName, filenameTable[0], dictFileName, cLevel, compressionParams);
|
operationResult = FIO_compressFilename(prefs, outFileName, filenameTable[0], dictFileName, cLevel, compressionParams);
|
||||||
else
|
else
|
||||||
operationResult = FIO_compressMultipleFilenames(prefs, filenameTable, outDirName, dstFilenameTable, filenameIdx, outFileName, suffix, dictFileName, cLevel, compressionParams);
|
operationResult = FIO_compressMultipleFilenames(prefs, filenameTable, outDirName, dstFilenameTable, filenameIdx, outFileName, suffix, dictFileName, cLevel, compressionParams);
|
||||||
|
|
||||||
|
if (dstFilenameTable)
|
||||||
|
UTIL_freeDestinationFilenameTable(dstFilenameTable, filenameIdx);
|
||||||
#else
|
#else
|
||||||
(void)suffix; (void)adapt; (void)rsyncable; (void)ultra; (void)cLevel; (void)ldmFlag; (void)literalCompressionMode; (void)targetCBlockSize; (void)streamSrcSize; (void)srcSizeHint; /* not used when ZSTD_NOCOMPRESS set */
|
(void)suffix; (void)adapt; (void)rsyncable; (void)ultra; (void)cLevel; (void)ldmFlag; (void)literalCompressionMode; (void)targetCBlockSize; (void)streamSrcSize; (void)srcSizeHint; /* not used when ZSTD_NOCOMPRESS set */
|
||||||
DISPLAY("Compression not supported \n");
|
DISPLAY("Compression not supported \n");
|
||||||
@ -1224,6 +1227,8 @@ int main(int argCount, const char* argv[])
|
|||||||
operationResult = FIO_decompressFilename(prefs, outFileName, filenameTable[0], dictFileName);
|
operationResult = FIO_decompressFilename(prefs, outFileName, filenameTable[0], dictFileName);
|
||||||
else
|
else
|
||||||
operationResult = FIO_decompressMultipleFilenames(prefs, filenameTable, filenameIdx, outDirName, dstFilenameTable, outFileName, dictFileName);
|
operationResult = FIO_decompressMultipleFilenames(prefs, filenameTable, filenameIdx, outDirName, dstFilenameTable, outFileName, dictFileName);
|
||||||
|
if (dstFilenameTable)
|
||||||
|
UTIL_freeDestinationFilenameTable(dstFilenameTable, filenameIdx);
|
||||||
#else
|
#else
|
||||||
DISPLAY("Decompression not supported \n");
|
DISPLAY("Decompression not supported \n");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user