summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
authorPrzemyslaw Skibinski <inikep@gmail.com>2016-11-04 15:56:01 (GMT)
committerPrzemyslaw Skibinski <inikep@gmail.com>2016-11-04 15:56:01 (GMT)
commitfbede33fd7f98f62d89031b4ee29cffdc90cceb8 (patch)
tree4995035dbd8a3ed310672e4ffccb77ca5653ad46 /programs
parent8ddaddc2d64451511d88634e2061766655289774 (diff)
downloadlz4-fbede33fd7f98f62d89031b4ee29cffdc90cceb8.zip
lz4-fbede33fd7f98f62d89031b4ee29cffdc90cceb8.tar.gz
lz4-fbede33fd7f98f62d89031b4ee29cffdc90cceb8.tar.bz2
fixed Travis tests
Diffstat (limited to 'programs')
-rw-r--r--programs/bench.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/programs/bench.c b/programs/bench.c
index 51c07f5..33f5fcf 100644
--- a/programs/bench.c
+++ b/programs/bench.c
@@ -353,22 +353,28 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
static size_t BMK_findMaxMem(U64 requiredMem)
{
- size_t const step = 64 MB;
- BYTE* testmem = NULL;
+ size_t step = 64 MB;
+ BYTE* testmem=NULL;
requiredMem = (((requiredMem >> 26) + 1) << 26);
- requiredMem += step;
+ requiredMem += 2*step;
if (requiredMem > maxMemory) requiredMem = maxMemory;
- do {
- testmem = (BYTE*)malloc((size_t)requiredMem);
- requiredMem -= step;
- } while (!testmem);
+ while (!testmem) {
+ if (requiredMem > step) requiredMem -= step;
+ else requiredMem >>= 1;
+ testmem = (BYTE*) malloc ((size_t)requiredMem);
+ }
+ free (testmem);
+
+ /* keep some space available */
+ if (requiredMem > step) requiredMem -= step;
+ else requiredMem >>= 1;
- free(testmem);
- return (size_t)(requiredMem);
+ return (size_t)requiredMem;
}
+
static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
const char* displayName, int cLevel, int cLevelLast,
const size_t* fileSizes, unsigned nbFiles)