opaque parameter for custom memory allocation functions

This commit is contained in:
inikep 2016-06-02 13:04:18 +02:00
parent e02bf99fa4
commit 2866951558
7 changed files with 76 additions and 69 deletions

View File

@ -33,6 +33,7 @@
/*-************************************* /*-*************************************
* Dependencies * Dependencies
***************************************/ ***************************************/
#include <stdlib.h> /* malloc */
#include "error_private.h" #include "error_private.h"
#include "zstd_static.h" /* declaration of ZSTD_isError, ZSTD_getErrorName, ZSTD_getErrorCode */ #include "zstd_static.h" /* declaration of ZSTD_isError, ZSTD_getErrorName, ZSTD_getErrorCode */
#include "zbuff.h" /* declaration of ZBUFF_isError, ZBUFF_getErrorName */ #include "zbuff.h" /* declaration of ZBUFF_isError, ZBUFF_getErrorName */
@ -70,3 +71,20 @@ const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorName(c
unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); } unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); }
const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); } const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
void* ZSTD_defaultAllocFunction(void* opaque, size_t size)
{
(void)opaque;
void* address = malloc(size);
/* DISPLAYLEVEL(4, "alloc %p, %d opaque=%d \n", address, (int)size, (int)opaque); */
return address;
}
void ZSTD_defaultFreeFunction(void* opaque, void* address)
{
(void)opaque;
/* if (address) DISPLAYLEVEL(4, "free %p opaque=%d \n", address, (int)opaque); */
free(address);
}

View File

@ -97,9 +97,14 @@ typedef struct {
ZSTD_frameParameters fParams; ZSTD_frameParameters fParams;
} ZSTD_parameters; } ZSTD_parameters;
typedef void* (*ZSTD_allocFunction) (size_t size); /* custom memory allocation functions */
typedef void (*ZSTD_freeFunction) (void* address); typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; } ZSTD_customMem; typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
void* ZSTD_defaultAllocFunction(void* opaque, size_t size);
void ZSTD_defaultFreeFunction(void* opaque, void* address);
static ZSTD_customMem const defaultCustomMem = { ZSTD_defaultAllocFunction, ZSTD_defaultFreeFunction, NULL };
/*-************************************* /*-*************************************

View File

@ -95,13 +95,12 @@ struct ZBUFF_CCtx_s {
size_t outBuffContentSize; size_t outBuffContentSize;
size_t outBuffFlushedSize; size_t outBuffFlushedSize;
ZBUFF_cStage stage; ZBUFF_cStage stage;
ZSTD_allocFunction customAlloc; ZSTD_customMem customMem;
ZSTD_freeFunction customFree;
}; /* typedef'd tp ZBUFF_CCtx within "zstd_buffered.h" */ }; /* typedef'd tp ZBUFF_CCtx within "zstd_buffered.h" */
ZBUFF_CCtx* ZBUFF_createCCtx(void) ZBUFF_CCtx* ZBUFF_createCCtx(void)
{ {
ZSTD_customMem customMem = { NULL, NULL }; ZSTD_customMem const customMem = { NULL, NULL, NULL };
return ZBUFF_createCCtx_advanced(customMem); return ZBUFF_createCCtx_advanced(customMem);
} }
@ -113,8 +112,7 @@ ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem)
{ {
zbc = (ZBUFF_CCtx*)calloc(1, sizeof(ZBUFF_CCtx)); zbc = (ZBUFF_CCtx*)calloc(1, sizeof(ZBUFF_CCtx));
if (zbc==NULL) return NULL; if (zbc==NULL) return NULL;
zbc->customAlloc = malloc; memcpy(&zbc->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
zbc->customFree = free;
zbc->zc = ZSTD_createCCtx(); zbc->zc = ZSTD_createCCtx();
return zbc; return zbc;
} }
@ -122,11 +120,10 @@ ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem)
if (!customMem.customAlloc || !customMem.customFree) if (!customMem.customAlloc || !customMem.customFree)
return NULL; return NULL;
zbc = (ZBUFF_CCtx*)customMem.customAlloc(sizeof(ZBUFF_CCtx)); zbc = (ZBUFF_CCtx*)customMem.customAlloc(customMem.opaque, sizeof(ZBUFF_CCtx));
if (zbc==NULL) return NULL; if (zbc==NULL) return NULL;
memset(zbc, 0, sizeof(ZBUFF_CCtx)); memset(zbc, 0, sizeof(ZBUFF_CCtx));
zbc->customAlloc = customMem.customAlloc; memcpy(&zbc->customMem, &customMem, sizeof(ZSTD_customMem));
zbc->customFree = customMem.customFree;
zbc->zc = ZSTD_createCCtx_advanced(customMem); zbc->zc = ZSTD_createCCtx_advanced(customMem);
return zbc; return zbc;
} }
@ -135,9 +132,9 @@ size_t ZBUFF_freeCCtx(ZBUFF_CCtx* zbc)
{ {
if (zbc==NULL) return 0; /* support free on NULL */ if (zbc==NULL) return 0; /* support free on NULL */
ZSTD_freeCCtx(zbc->zc); ZSTD_freeCCtx(zbc->zc);
zbc->customFree(zbc->inBuff); zbc->customMem.customFree(zbc->customMem.opaque, zbc->inBuff);
zbc->customFree(zbc->outBuff); zbc->customMem.customFree(zbc->customMem.opaque, zbc->outBuff);
zbc->customFree(zbc); zbc->customMem.customFree(zbc->customMem.opaque, zbc);
return 0; return 0;
} }
@ -152,16 +149,16 @@ size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
{ size_t const neededInBuffSize = (size_t)1 << params.cParams.windowLog; { size_t const neededInBuffSize = (size_t)1 << params.cParams.windowLog;
if (zbc->inBuffSize < neededInBuffSize) { if (zbc->inBuffSize < neededInBuffSize) {
zbc->inBuffSize = neededInBuffSize; zbc->inBuffSize = neededInBuffSize;
zbc->customFree(zbc->inBuff); /* should not be necessary */ zbc->customMem.customFree(zbc->customMem.opaque, zbc->inBuff); /* should not be necessary */
zbc->inBuff = (char*)zbc->customAlloc(neededInBuffSize); zbc->inBuff = (char*)zbc->customMem.customAlloc(zbc->customMem.opaque, neededInBuffSize);
if (zbc->inBuff == NULL) return ERROR(memory_allocation); if (zbc->inBuff == NULL) return ERROR(memory_allocation);
} }
zbc->blockSize = MIN(ZSTD_BLOCKSIZE_MAX, neededInBuffSize/2); zbc->blockSize = MIN(ZSTD_BLOCKSIZE_MAX, neededInBuffSize/2);
} }
if (zbc->outBuffSize < ZSTD_compressBound(zbc->blockSize)+1) { if (zbc->outBuffSize < ZSTD_compressBound(zbc->blockSize)+1) {
zbc->outBuffSize = ZSTD_compressBound(zbc->blockSize)+1; zbc->outBuffSize = ZSTD_compressBound(zbc->blockSize)+1;
zbc->customFree(zbc->outBuff); /* should not be necessary */ zbc->customMem.customFree(zbc->customMem.opaque, zbc->outBuff); /* should not be necessary */
zbc->outBuff = (char*)zbc->customAlloc(zbc->outBuffSize); zbc->outBuff = (char*)zbc->customMem.customAlloc(zbc->customMem.opaque, zbc->outBuffSize);
if (zbc->outBuff == NULL) return ERROR(memory_allocation); if (zbc->outBuff == NULL) return ERROR(memory_allocation);
} }

View File

@ -107,8 +107,7 @@ struct ZSTD_CCtx_s
size_t workSpaceSize; size_t workSpaceSize;
size_t blockSize; size_t blockSize;
XXH64_state_t xxhState; XXH64_state_t xxhState;
ZSTD_allocFunction customAlloc; ZSTD_customMem customMem;
ZSTD_freeFunction customFree;
seqStore_t seqStore; /* sequences storage ptrs */ seqStore_t seqStore; /* sequences storage ptrs */
U32* hashTable; U32* hashTable;
@ -123,7 +122,7 @@ struct ZSTD_CCtx_s
ZSTD_CCtx* ZSTD_createCCtx(void) ZSTD_CCtx* ZSTD_createCCtx(void)
{ {
ZSTD_customMem customMem = { NULL, NULL }; ZSTD_customMem const customMem = { NULL, NULL, NULL };
return ZSTD_createCCtx_advanced(customMem); return ZSTD_createCCtx_advanced(customMem);
} }
@ -135,28 +134,24 @@ ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem)
{ {
ctx = (ZSTD_CCtx*) calloc(1, sizeof(ZSTD_CCtx)); ctx = (ZSTD_CCtx*) calloc(1, sizeof(ZSTD_CCtx));
if (!ctx) return NULL; if (!ctx) return NULL;
memcpy(&ctx->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
ctx->customAlloc = malloc;
ctx->customFree = free;
return ctx; return ctx;
} }
if (!customMem.customAlloc || !customMem.customFree) if (!customMem.customAlloc || !customMem.customFree)
return NULL; return NULL;
ctx = (ZSTD_CCtx*) customMem.customAlloc(sizeof(ZSTD_CCtx)); ctx = (ZSTD_CCtx*) customMem.customAlloc(customMem.opaque, sizeof(ZSTD_CCtx));
if (!ctx) return NULL; if (!ctx) return NULL;
memset(ctx, 0, sizeof(ZSTD_CCtx)); memset(ctx, 0, sizeof(ZSTD_CCtx));
ctx->customAlloc = customMem.customAlloc; memcpy(&ctx->customMem, &customMem, sizeof(ZSTD_customMem));
ctx->customFree = customMem.customFree;
return ctx; return ctx;
} }
size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx) size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx)
{ {
cctx->customFree(cctx->workSpace); cctx->customMem.customFree(cctx->customMem.opaque, cctx->workSpace);
cctx->customFree(cctx); cctx->customMem.customFree(cctx->customMem.opaque, cctx);
return 0; /* reserved as a potential error code in the future */ return 0; /* reserved as a potential error code in the future */
} }
@ -262,8 +257,8 @@ static size_t ZSTD_resetCCtx_advanced (ZSTD_CCtx* zc,
size_t const neededSpace = tableSpace + (256*sizeof(U32)) /* huffTable */ + tokenSpace size_t const neededSpace = tableSpace + (256*sizeof(U32)) /* huffTable */ + tokenSpace
+ ((params.cParams.strategy == ZSTD_btopt) ? optSpace : 0); + ((params.cParams.strategy == ZSTD_btopt) ? optSpace : 0);
if (zc->workSpaceSize < neededSpace) { if (zc->workSpaceSize < neededSpace) {
zc->customFree(zc->workSpace); zc->customMem.customFree(zc->customMem.opaque, zc->workSpace);
zc->workSpace = zc->customAlloc(neededSpace); zc->workSpace = zc->customMem.customAlloc(zc->customMem.opaque, neededSpace);
if (zc->workSpace == NULL) return ERROR(memory_allocation); if (zc->workSpace == NULL) return ERROR(memory_allocation);
zc->workSpaceSize = neededSpace; zc->workSpaceSize = neededSpace;
} } } }
@ -322,8 +317,7 @@ size_t ZSTD_copyCCtx(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx)
if (srcCCtx->stage!=1) return ERROR(stage_wrong); if (srcCCtx->stage!=1) return ERROR(stage_wrong);
dstCCtx->hashLog3 = srcCCtx->hashLog3; /* must be before ZSTD_resetCCtx_advanced */ dstCCtx->hashLog3 = srcCCtx->hashLog3; /* must be before ZSTD_resetCCtx_advanced */
dstCCtx->customAlloc = srcCCtx->customAlloc; memcpy(&dstCCtx->customMem, &srcCCtx->customMem, sizeof(ZSTD_customMem));
dstCCtx->customFree = srcCCtx->customFree;
ZSTD_resetCCtx_advanced(dstCCtx, srcCCtx->params, 0); ZSTD_resetCCtx_advanced(dstCCtx, srcCCtx->params, 0);
dstCCtx->params.fParams.contentSizeFlag = 0; /* content size different from the one set during srcCCtx init */ dstCCtx->params.fParams.contentSizeFlag = 0; /* content size different from the one set during srcCCtx init */
@ -2487,10 +2481,9 @@ size_t ZSTD_compress(void* dst, size_t dstCapacity, const void* src, size_t srcS
size_t result; size_t result;
ZSTD_CCtx ctxBody; ZSTD_CCtx ctxBody;
memset(&ctxBody, 0, sizeof(ctxBody)); memset(&ctxBody, 0, sizeof(ctxBody));
ctxBody.customAlloc = malloc; memcpy(&ctxBody.customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
ctxBody.customFree = free;
result = ZSTD_compressCCtx(&ctxBody, dst, dstCapacity, src, srcSize, compressionLevel); result = ZSTD_compressCCtx(&ctxBody, dst, dstCapacity, src, srcSize, compressionLevel);
ctxBody.customFree(ctxBody.workSpace); /* can't free ctxBody, since it's on stack; just free heap content */ ctxBody.customMem.customFree(ctxBody.customMem.opaque, ctxBody.workSpace); /* can't free ctxBody, since it's on stack; just free heap content */
return result; return result;
} }

View File

@ -82,14 +82,13 @@ struct ZBUFF_DCtx_s {
size_t blockSize; size_t blockSize;
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX]; BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
size_t lhSize; size_t lhSize;
ZSTD_allocFunction customAlloc; ZSTD_customMem customMem;
ZSTD_freeFunction customFree;
}; /* typedef'd to ZBUFF_DCtx within "zstd_buffered.h" */ }; /* typedef'd to ZBUFF_DCtx within "zstd_buffered.h" */
ZBUFF_DCtx* ZBUFF_createDCtx(void) ZBUFF_DCtx* ZBUFF_createDCtx(void)
{ {
ZSTD_customMem customMem = { NULL, NULL }; ZSTD_customMem const customMem = { NULL, NULL, NULL };
return ZBUFF_createDCtx_advanced(customMem); return ZBUFF_createDCtx_advanced(customMem);
} }
@ -101,8 +100,7 @@ ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
{ {
zbd = (ZBUFF_DCtx*)calloc(1, sizeof(ZBUFF_DCtx)); zbd = (ZBUFF_DCtx*)calloc(1, sizeof(ZBUFF_DCtx));
if (zbd==NULL) return NULL; if (zbd==NULL) return NULL;
zbd->customAlloc = malloc; memcpy(&zbd->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
zbd->customFree = free;
zbd->zd = ZSTD_createDCtx(); zbd->zd = ZSTD_createDCtx();
zbd->stage = ZBUFFds_init; zbd->stage = ZBUFFds_init;
return zbd; return zbd;
@ -111,11 +109,10 @@ ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
if (!customMem.customAlloc || !customMem.customFree) if (!customMem.customAlloc || !customMem.customFree)
return NULL; return NULL;
zbd = (ZBUFF_DCtx*)customMem.customAlloc(sizeof(ZBUFF_DCtx)); zbd = (ZBUFF_DCtx*)customMem.customAlloc(customMem.opaque, sizeof(ZBUFF_DCtx));
if (zbd==NULL) return NULL; if (zbd==NULL) return NULL;
memset(zbd, 0, sizeof(ZBUFF_DCtx)); memset(zbd, 0, sizeof(ZBUFF_DCtx));
zbd->customAlloc = customMem.customAlloc; memcpy(&zbd->customMem, &customMem, sizeof(ZSTD_customMem));
zbd->customFree = customMem.customFree;
zbd->zd = ZSTD_createDCtx_advanced(customMem); zbd->zd = ZSTD_createDCtx_advanced(customMem);
zbd->stage = ZBUFFds_init; zbd->stage = ZBUFFds_init;
return zbd; return zbd;
@ -125,9 +122,9 @@ size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
{ {
if (zbd==NULL) return 0; /* support free on null */ if (zbd==NULL) return 0; /* support free on null */
ZSTD_freeDCtx(zbd->zd); ZSTD_freeDCtx(zbd->zd);
zbd->customFree(zbd->inBuff); zbd->customMem.customFree(zbd->customMem.opaque, zbd->inBuff);
zbd->customFree(zbd->outBuff); zbd->customMem.customFree(zbd->customMem.opaque, zbd->outBuff);
zbd->customFree(zbd); zbd->customMem.customFree(zbd->customMem.opaque, zbd);
return 0; return 0;
} }
@ -198,16 +195,16 @@ size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,
{ size_t const blockSize = MIN(1 << zbd->fParams.windowLog, ZSTD_BLOCKSIZE_MAX); { size_t const blockSize = MIN(1 << zbd->fParams.windowLog, ZSTD_BLOCKSIZE_MAX);
zbd->blockSize = blockSize; zbd->blockSize = blockSize;
if (zbd->inBuffSize < blockSize) { if (zbd->inBuffSize < blockSize) {
zbd->customFree(zbd->inBuff); zbd->customMem.customFree(zbd->customMem.opaque, zbd->inBuff);
zbd->inBuffSize = blockSize; zbd->inBuffSize = blockSize;
zbd->inBuff = (char*)zbd->customAlloc(blockSize); zbd->inBuff = (char*)zbd->customMem.customAlloc(zbd->customMem.opaque, blockSize);
if (zbd->inBuff == NULL) return ERROR(memory_allocation); if (zbd->inBuff == NULL) return ERROR(memory_allocation);
} }
{ size_t const neededOutSize = ((size_t)1 << zbd->fParams.windowLog) + blockSize; { size_t const neededOutSize = ((size_t)1 << zbd->fParams.windowLog) + blockSize;
if (zbd->outBuffSize < neededOutSize) { if (zbd->outBuffSize < neededOutSize) {
zbd->customFree(zbd->outBuff); zbd->customMem.customFree(zbd->customMem.opaque, zbd->outBuff);
zbd->outBuffSize = neededOutSize; zbd->outBuffSize = neededOutSize;
zbd->outBuff = (char*)zbd->customAlloc(neededOutSize); zbd->outBuff = (char*)zbd->customMem.customAlloc(zbd->customMem.opaque, neededOutSize);
if (zbd->outBuff == NULL) return ERROR(memory_allocation); if (zbd->outBuff == NULL) return ERROR(memory_allocation);
} } } } } }
zbd->stage = ZBUFFds_read; zbd->stage = ZBUFFds_read;

View File

@ -120,8 +120,7 @@ struct ZSTD_DCtx_s
size_t headerSize; size_t headerSize;
ZSTD_frameParams fParams; ZSTD_frameParams fParams;
XXH64_state_t xxhState; XXH64_state_t xxhState;
ZSTD_allocFunction customAlloc; ZSTD_customMem customMem;
ZSTD_freeFunction customFree;
blockType_t bType; /* used in ZSTD_decompressContinue(), to transfer blockType between header decoding and block decoding stages */ blockType_t bType; /* used in ZSTD_decompressContinue(), to transfer blockType between header decoding and block decoding stages */
ZSTD_dStage stage; ZSTD_dStage stage;
U32 dictID; U32 dictID;
@ -156,9 +155,7 @@ ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
if (!customMem.customAlloc && !customMem.customFree) { if (!customMem.customAlloc && !customMem.customFree) {
dctx = (ZSTD_DCtx*) malloc(sizeof(ZSTD_DCtx)); dctx = (ZSTD_DCtx*) malloc(sizeof(ZSTD_DCtx));
if (!dctx) return NULL; if (!dctx) return NULL;
dctx->customAlloc = malloc; memcpy(&dctx->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
dctx->customFree = free;
ZSTD_decompressBegin(dctx); ZSTD_decompressBegin(dctx);
return dctx; return dctx;
} }
@ -166,25 +163,23 @@ ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
if (!customMem.customAlloc || !customMem.customFree) if (!customMem.customAlloc || !customMem.customFree)
return NULL; return NULL;
dctx = (ZSTD_DCtx*) customMem.customAlloc(sizeof(ZSTD_DCtx)); dctx = (ZSTD_DCtx*) customMem.customAlloc(customMem.opaque, sizeof(ZSTD_DCtx));
if (!dctx) return NULL; if (!dctx) return NULL;
dctx->customAlloc = customMem.customAlloc; memcpy(&dctx->customMem, &customMem, sizeof(ZSTD_customMem));
dctx->customFree = customMem.customFree;
ZSTD_decompressBegin(dctx); ZSTD_decompressBegin(dctx);
return dctx; return dctx;
} }
ZSTD_DCtx* ZSTD_createDCtx(void) ZSTD_DCtx* ZSTD_createDCtx(void)
{ {
ZSTD_customMem const customMem = { NULL, NULL }; ZSTD_customMem const customMem = { NULL, NULL, NULL };
return ZSTD_createDCtx_advanced(customMem); return ZSTD_createDCtx_advanced(customMem);
} }
size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx) size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx)
{ {
dctx->customFree(dctx); dctx->customMem.customFree(dctx->customMem.opaque, dctx);
return 0; /* reserved as a potential error code in the future */ return 0; /* reserved as a potential error code in the future */
} }

View File

@ -129,16 +129,18 @@ static unsigned FUZ_highbit32(U32 v32)
} }
*/ */
void* ZBUFF_allocFunction(size_t size) void* ZBUFF_allocFunction(void* opaque, size_t size)
{ {
(void)opaque;
void* address = malloc(size); void* address = malloc(size);
/* DISPLAYLEVEL(4, "alloc %p, %d \n", address, (int)size); */ /* DISPLAYLEVEL(4, "alloc %p, %d opaque=%d \n", address, (int)size, (int)opaque); */
return address; return address;
} }
void ZBUFF_freeFunction(void* address) void ZBUFF_freeFunction(void* opaque, void* address)
{ {
/* if (address) DISPLAYLEVEL(4, "free %p \n", address); */ (void)opaque;
/* if (address) DISPLAYLEVEL(4, "free %p opaque=%d \n", address, (int)opaque); */
free(address); free(address);
} }
@ -512,8 +514,8 @@ int main(int argc, const char** argv)
int result=0; int result=0;
U32 mainPause = 0; U32 mainPause = 0;
const char* programName = argv[0]; const char* programName = argv[0];
ZSTD_customMem customMem = { ZBUFF_allocFunction, ZBUFF_freeFunction }; ZSTD_customMem customMem = { ZBUFF_allocFunction, ZBUFF_freeFunction, (void*)777 };
ZSTD_customMem customNULL = { NULL, NULL }; ZSTD_customMem customNULL = { NULL, NULL, NULL };
/* Check command line */ /* Check command line */
for(argNb=1; argNb<argc; argNb++) { for(argNb=1; argNb<argc; argNb++) {