mirror of
https://github.com/facebook/zstd.git
synced 2025-10-09 00:05:28 -04:00
expose ZSTD_compress_generic_simpleArgs()
which is a binding towards ZSTD_compress_generic() using only integral types for arguments.
This commit is contained in:
parent
ae728a43b8
commit
deee6e523f
@ -698,6 +698,19 @@ size_t ZSTD_CDict_loadDictionary(ZSTD_CDict* cdict, const void* dict, size_t dic
|
|||||||
|
|
||||||
</p></pre><BR>
|
</p></pre><BR>
|
||||||
|
|
||||||
|
<pre><b>size_t ZSTD_compress_generic_simpleArgs (
|
||||||
|
ZSTD_CCtx* cctx,
|
||||||
|
void* dst, size_t dstCapacity, size_t* dstPos,
|
||||||
|
const void* src, size_t srcSize, size_t* srcPos,
|
||||||
|
ZSTD_EndDirective endOp);
|
||||||
|
</b><p> Same as ZSTD_compress_generic(),
|
||||||
|
but using only simple integral types as arguments.
|
||||||
|
Argument list is less expressive than ZSTD_{in,out}Buffer,
|
||||||
|
but can be helpful for binders towards dynamic languages
|
||||||
|
which have troubles handling structures containing memory pointers.
|
||||||
|
|
||||||
|
</p></pre><BR>
|
||||||
|
|
||||||
<a name="Chapter15"></a><h2>Advanced decompression functions</h2><pre></pre>
|
<a name="Chapter15"></a><h2>Advanced decompression functions</h2><pre></pre>
|
||||||
|
|
||||||
<pre><b>unsigned ZSTD_isFrame(const void* buffer, size_t size);
|
<pre><b>unsigned ZSTD_isFrame(const void* buffer, size_t size);
|
||||||
|
@ -3710,49 +3710,54 @@ size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuf
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_compress_generic_integral (
|
size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
|
||||||
ZSTD_CCtx* cctx,
|
ZSTD_outBuffer* output,
|
||||||
void* dst, size_t dstCapacity, size_t* dstPos,
|
ZSTD_inBuffer* input,
|
||||||
const void* src, size_t srcSize, size_t* srcPos,
|
|
||||||
ZSTD_EndDirective endOp)
|
ZSTD_EndDirective endOp)
|
||||||
{
|
{
|
||||||
/* check conditions */
|
/* check conditions */
|
||||||
if (*dstPos > dstCapacity) return ERROR(GENERIC);
|
if (output->pos > output->size) return ERROR(GENERIC);
|
||||||
if (*srcPos > srcSize) return ERROR(GENERIC);
|
if (input->pos > input->size) return ERROR(GENERIC);
|
||||||
|
|
||||||
assert(cctx!=NULL);
|
assert(cctx!=NULL);
|
||||||
if (cctx->streamStage == zcss_init) {
|
if (cctx->streamStage == zcss_init) {
|
||||||
/* transparent reset */
|
/* transparent reset */
|
||||||
ZSTD_parameters params = cctx->requestedParams;
|
ZSTD_parameters params = cctx->requestedParams;
|
||||||
DEBUGLOG(5, "ZSTD_compress_generic_integral : transparent reset");
|
DEBUGLOG(5, "ZSTD_compress_generic : transparent reset");
|
||||||
if (cctx->compressionLevel != ZSTD_CLEVEL_CUSTOM)
|
if (cctx->compressionLevel != ZSTD_CLEVEL_CUSTOM)
|
||||||
params.cParams = ZSTD_getCParams(cctx->compressionLevel,
|
params.cParams = ZSTD_getCParams(cctx->compressionLevel,
|
||||||
cctx->frameContentSize, 0 /* dictSize */);
|
cctx->frameContentSize, 0 /* dictSize */);
|
||||||
CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->frameContentSize) );
|
CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->frameContentSize) );
|
||||||
}
|
}
|
||||||
|
|
||||||
{ size_t sizeRead = srcSize - *srcPos;
|
{ size_t sizeRead = input->size - input->pos;
|
||||||
size_t sizeWritten = dstCapacity - *dstPos;
|
size_t sizeWritten = output->size - output->pos;
|
||||||
DEBUGLOG(5, "starting ZSTD_compressStream_generic");
|
DEBUGLOG(5, "starting ZSTD_compressStream_generic");
|
||||||
CHECK_F( ZSTD_compressStream_generic(cctx,
|
CHECK_F( ZSTD_compressStream_generic(cctx,
|
||||||
(char*)dst + *dstPos, &sizeWritten,
|
(char*)output->dst + output->pos, &sizeWritten,
|
||||||
(const char*)src + *srcPos, &sizeRead, endOp) );
|
(const char*)input->src + input->pos, &sizeRead, endOp) );
|
||||||
*srcPos += sizeRead;
|
input->pos += sizeRead;
|
||||||
*dstPos += sizeWritten;
|
output->pos += sizeWritten;
|
||||||
}
|
}
|
||||||
DEBUGLOG(5, "completing ZSTD_compress_generic_integral");
|
DEBUGLOG(5, "completing ZSTD_compress_generic_integral");
|
||||||
return cctx->outBuffContentSize - cctx->outBuffFlushedSize; /* remaining to flush */
|
return cctx->outBuffContentSize - cctx->outBuffFlushedSize; /* remaining to flush */
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
|
size_t ZSTD_compress_generic_simpleArgs (
|
||||||
ZSTD_outBuffer* output,
|
ZSTD_CCtx* cctx,
|
||||||
ZSTD_inBuffer* input,
|
void* dst, size_t dstCapacity, size_t* dstPos,
|
||||||
|
const void* src, size_t srcSize, size_t* srcPos,
|
||||||
ZSTD_EndDirective endOp)
|
ZSTD_EndDirective endOp)
|
||||||
{
|
{
|
||||||
return ZSTD_compress_generic_integral(cctx,
|
ZSTD_outBuffer output = { dst, dstCapacity, *dstPos };
|
||||||
output->dst, output->size, &output->pos,
|
ZSTD_inBuffer input = { src, srcSize, *srcPos };
|
||||||
input->src, input->size, &input->pos,
|
|
||||||
endOp);
|
size_t const hint = ZSTD_compress_generic(cctx, &output, &input, endOp);
|
||||||
|
if (ZSTD_isError(hint)) return hint;
|
||||||
|
|
||||||
|
*dstPos = output.pos;
|
||||||
|
*srcPos = input.pos;
|
||||||
|
return hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -783,7 +783,8 @@ static size_t ZSTDMT_flushStream_internal(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* outp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check if there is any data available to flush */
|
/* check if there is any data available to flush */
|
||||||
DEBUGLOG(5, "zcs->doneJobID : %u ; zcs->nextJobID : %u ", zcs->doneJobID, zcs->nextJobID);
|
DEBUGLOG(5, "zcs->doneJobID : %u ; zcs->nextJobID : %u",
|
||||||
|
zcs->doneJobID, zcs->nextJobID);
|
||||||
return ZSTDMT_flushNextJob(zcs, output, 1);
|
return ZSTDMT_flushNextJob(zcs, output, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
lib/zstd.h
14
lib/zstd.h
@ -823,6 +823,20 @@ ZSTDLIB_API size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
|
|||||||
ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx); /* Not ready yet ! */
|
ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx); /* Not ready yet ! */
|
||||||
|
|
||||||
|
|
||||||
|
/*! ZSTD_compress_generic_simpleArgs() :
|
||||||
|
* Same as ZSTD_compress_generic(),
|
||||||
|
* but using only simple integral types as arguments.
|
||||||
|
* Argument list is less expressive than ZSTD_{in,out}Buffer,
|
||||||
|
* but can be helpful for binders towards dynamic languages
|
||||||
|
* which have troubles handling structures containing memory pointers.
|
||||||
|
*/
|
||||||
|
size_t ZSTD_compress_generic_simpleArgs (
|
||||||
|
ZSTD_CCtx* cctx,
|
||||||
|
void* dst, size_t dstCapacity, size_t* dstPos,
|
||||||
|
const void* src, size_t srcSize, size_t* srcPos,
|
||||||
|
ZSTD_EndDirective endOp);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*--- Advanced decompression functions ---*/
|
/*--- Advanced decompression functions ---*/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user