lz4io : removed one malloc
authorYann Collet <yann.collet.73@gmail.com>
Mon, 29 Jun 2015 04:24:09 +0000 (20:24 -0800)
committerYann Collet <yann.collet.73@gmail.com>
Mon, 29 Jun 2015 04:24:09 +0000 (20:24 -0800)
programs/lz4io.c

index 19db03b..d92634a 100644 (file)
@@ -876,9 +876,11 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE
 }
 
 
+#define PTSIZE  (64 KB)
+#define PTSIZET (PTSIZE / sizeof(size_t))
 static unsigned long long LZ4IO_passThrough(FILE* finput, FILE* foutput, unsigned char MNstore[MAGICNUMBER_SIZE])
 {
-    void* buffer = malloc(64 KB);
+       size_t buffer[PTSIZET];
     size_t read = 1, sizeCheck;
     unsigned long long total = MAGICNUMBER_SIZE;
     unsigned storedSkips = 0;
@@ -888,13 +890,12 @@ static unsigned long long LZ4IO_passThrough(FILE* finput, FILE* foutput, unsigne
 
     while (read)
     {
-        read = fread(buffer, 1, 64 KB, finput);
+        read = fread(buffer, 1, PTSIZE, finput);
         total += read;
         storedSkips = LZ4IO_fwriteSparse(foutput, buffer, read, storedSkips);
     }
 
     LZ4IO_fwriteSparseEnd(foutput, storedSkips);
-    free(buffer);
     return total;
 }