From: Yann Collet Date: Tue, 15 Mar 2016 20:44:39 +0000 (+0100) Subject: minor refactoring, from `char*` to `const char*` X-Git-Tag: v0.6.0^2~17^2~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69afc716d3442c45a57ebf51e0e579dfffb30c51;p=thirdparty%2Fzstd.git minor refactoring, from `char*` to `const char*` --- diff --git a/programs/fullbench.c b/programs/fullbench.c index fb9c7ed35..125dc809a 100644 --- a/programs/fullbench.c +++ b/programs/fullbench.c @@ -180,7 +180,7 @@ static size_t BMK_findMaxMem(U64 requiredMem) } -static U64 BMK_GetFileSize(char* infilename) +static U64 BMK_GetFileSize(const char* infilename) { int r; #if defined(_MSC_VER) @@ -345,8 +345,7 @@ size_t benchMem(void* src, size_t srcSize, U32 benchNb) ZSTD_compress(dstBuff, dstBuffSize, src, srcSize, 1); /* it would be better to use direct block compression here */ ip += 5; /* Skip frame Header */ blockSize = ZSTD_getcBlockSize(ip, dstBuffSize, &bp); /* Get 1st block type */ - if (bp.blockType != bt_compressed) - { + if (bp.blockType != bt_compressed) { DISPLAY("ZSTD_decodeSeqHeaders : impossible to test on this sample (not compressible)\n"); goto _cleanOut; } @@ -374,8 +373,7 @@ size_t benchMem(void* src, size_t srcSize, U32 benchNb) { size_t i; for (i=0; i inFileSize) benchedSize = (size_t)inFileSize; - if (benchedSize < inFileSize) { + if (benchedSize < inFileSize) DISPLAY("Not enough memory for '%s' full size; testing %i MB only...\n", inFileName, (int)(benchedSize>>20)); - } /* Alloc */ - origBuff = (char*) malloc((size_t)benchedSize); - if(!origBuff) { - DISPLAY("\nError: not enough memory!\n"); - fclose(inFile); - return 12; - } + origBuff = malloc(benchedSize); + if (!origBuff) { DISPLAY("\nError: not enough memory!\n"); fclose(inFile); return 12; } /* Fill input buffer */ DISPLAY("Loading %s... \r", inFileName); @@ -496,7 +480,7 @@ int benchFiles(char** fileNamesTable, int nbFiles, U32 benchNb) } -static int usage(char* exename) +static int usage(const char* exename) { DISPLAY( "Usage :\n"); DISPLAY( " %s [arg] file1 file2 ... fileX\n", exename); @@ -514,20 +498,20 @@ static int usage_advanced(void) return 0; } -static int badusage(char* exename) +static int badusage(const char* exename) { DISPLAY("Wrong parameters\n"); usage(exename); return 0; } -int main(int argc, char** argv) +int main(int argc, const char** argv) { int i, filenamesStart=0, result; - char* exename=argv[0]; - char* input_filename=0; + const char* exename=argv[0]; + const char* input_filename=0; U32 benchNb = 0, main_pause = 0; // Welcome message @@ -537,7 +521,7 @@ int main(int argc, char** argv) for(i=1; i= '0') && (argument[1]<= '9')) - { + while ((argument[1]>= '0') && (argument[1]<= '9')) { benchNb *= 10; benchNb += argument[1] - '0'; argument++; @@ -570,8 +553,7 @@ int main(int argc, char** argv) /* Modify Nb Iterations */ case 'i': - if ((argument[1] >='0') && (argument[1] <='9')) - { + if ((argument[1] >='0') && (argument[1] <='9')) { int iters = argument[1] - '0'; BMK_SetNbIterations(iters); argument++; @@ -580,10 +562,8 @@ int main(int argc, char** argv) /* Select specific algorithm to bench */ case 'P': - { - U32 proba32 = 0; - while ((argument[1]>= '0') && (argument[1]<= '9')) - { + { U32 proba32 = 0; + while ((argument[1]>= '0') && (argument[1]<= '9')) { proba32 *= 10; proba32 += argument[1] - '0'; argument++;