]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
getTotalFileSize moved to common/util.h
authorinikep <inikep@gmail.com>
Thu, 28 Apr 2016 14:50:13 +0000 (16:50 +0200)
committerinikep <inikep@gmail.com>
Thu, 28 Apr 2016 14:50:13 +0000 (16:50 +0200)
lib/common/util.h
programs/bench.c
programs/dibio.c

index 3eef4b1d0ae40157174c87be520978bf32776124..1de1efd86e92d45c13d1b851e0808402bcb2e04b 100644 (file)
@@ -138,6 +138,16 @@ UTIL_STATIC U64 UTIL_getFileSize(const char* infilename)
 }
 
 
+UTIL_STATIC U64 UTIL_getTotalFileSize(const char** fileNamesTable, unsigned nbFiles)
+{
+    U64 total = 0;
+    unsigned n;
+    for (n=0; n<nbFiles; n++)
+        total += UTIL_getFileSize(fileNamesTable[n]);
+    return total;
+}
+
+
 UTIL_STATIC U32 UTIL_isDirectory(const char* infilename)
 {
     int r;
index 831cc27ef722202a7c5b124ab6c704e9d670f751..dd9f289b653ffc710b39caccca8ea6e3f72519fe 100644 (file)
 /* *************************************
 *  Includes
 ***************************************/
+#include "util.h"        /* UTIL_GetFileSize */
 #include <stdlib.h>      /* malloc, free */
 #include <string.h>      /* memset */
 #include <stdio.h>       /* fprintf, fopen, ftello64 */
 
-#include "util.h"        /* UTIL_GetFileSize */
 #include "mem.h"
 #include "zstd_static.h"
 #include "datagen.h"     /* RDG_genBuffer */
@@ -421,14 +421,6 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
     }
 }
 
-static U64 BMK_getTotalFileSize(const char** fileNamesTable, unsigned nbFiles)
-{
-    U64 total = 0;
-    unsigned n;
-    for (n=0; n<nbFiles; n++)
-        total += UTIL_getFileSize(fileNamesTable[n]);
-    return total;
-}
 
 /*! BMK_loadFiles() :
     Loads `buffer` with content of files listed within `fileNamesTable`.
@@ -469,7 +461,7 @@ static void BMK_benchFileTable(const char** fileNamesTable, unsigned nbFiles,
     void* dictBuffer = NULL;
     size_t dictBufferSize = 0;
     size_t* fileSizes = (size_t*)malloc(nbFiles * sizeof(size_t));
-    U64 totalSizeToLoad = BMK_getTotalFileSize(fileNamesTable, nbFiles);
+    U64 totalSizeToLoad = UTIL_getTotalFileSize(fileNamesTable, nbFiles);
     char mfName[20] = {0};
     const char* displayName = NULL;
 
index c06d186bed089c30a699e3132c5c195dfe808575..ccdf5057e86694356de9476b6d5024f66e2dd5f1 100644 (file)
@@ -105,16 +105,6 @@ const char* DiB_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCo
 /* ********************************************************
 *  File related operations
 **********************************************************/
-static unsigned long long DiB_getTotalFileSize(const char** fileNamesTable, unsigned nbFiles)
-{
-    unsigned long long total = 0;
-    unsigned n;
-    for (n=0; n<nbFiles; n++)
-        total += UTIL_getFileSize(fileNamesTable[n]);
-    return total;
-}
-
-
 static void DiB_loadFiles(void* buffer, size_t bufferSize,
                           size_t* fileSizes,
                           const char** fileNamesTable, unsigned nbFiles)
@@ -209,7 +199,7 @@ int DiB_trainFromFiles(const char* dictFileName, unsigned maxDictSize,
     void* srcBuffer;
     size_t benchedSize;
     size_t* fileSizes = (size_t*)malloc(nbFiles * sizeof(size_t));
-    unsigned long long totalSizeToLoad = DiB_getTotalFileSize(fileNamesTable, nbFiles);
+    unsigned long long totalSizeToLoad = UTIL_getTotalFileSize(fileNamesTable, nbFiles);
     void* dictBuffer = malloc(maxDictSize);
     size_t dictSize;
     int result = 0;