expose ZSTD_compress_generic_simpleArgs()
which is a binding towards ZSTD_compress_generic()
using only integral types for arguments.
diff --git a/doc/zstd_manual.html b/doc/zstd_manual.html
index 2c66409..3b7f328 100644
--- a/doc/zstd_manual.html
+++ b/doc/zstd_manual.html
@@ -698,6 +698,19 @@
</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>
<pre><b>unsigned ZSTD_isFrame(const void* buffer, size_t size);
diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c
index 7c2fd52..b046a2c 100644
--- a/lib/compress/zstd_compress.c
+++ b/lib/compress/zstd_compress.c
@@ -3710,49 +3710,54 @@
return result;
}
-size_t ZSTD_compress_generic_integral (
- ZSTD_CCtx* cctx,
- void* dst, size_t dstCapacity, size_t* dstPos,
- const void* src, size_t srcSize, size_t* srcPos,
- ZSTD_EndDirective endOp)
+size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp)
{
/* check conditions */
- if (*dstPos > dstCapacity) return ERROR(GENERIC);
- if (*srcPos > srcSize) return ERROR(GENERIC);
+ if (output->pos > output->size) return ERROR(GENERIC);
+ if (input->pos > input->size) return ERROR(GENERIC);
assert(cctx!=NULL);
if (cctx->streamStage == zcss_init) {
/* transparent reset */
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)
params.cParams = ZSTD_getCParams(cctx->compressionLevel,
cctx->frameContentSize, 0 /* dictSize */);
CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->frameContentSize) );
}
- { size_t sizeRead = srcSize - *srcPos;
- size_t sizeWritten = dstCapacity - *dstPos;
+ { size_t sizeRead = input->size - input->pos;
+ size_t sizeWritten = output->size - output->pos;
DEBUGLOG(5, "starting ZSTD_compressStream_generic");
CHECK_F( ZSTD_compressStream_generic(cctx,
- (char*)dst + *dstPos, &sizeWritten,
- (const char*)src + *srcPos, &sizeRead, endOp) );
- *srcPos += sizeRead;
- *dstPos += sizeWritten;
+ (char*)output->dst + output->pos, &sizeWritten,
+ (const char*)input->src + input->pos, &sizeRead, endOp) );
+ input->pos += sizeRead;
+ output->pos += sizeWritten;
}
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,
- ZSTD_outBuffer* output,
- ZSTD_inBuffer* input,
- ZSTD_EndDirective endOp)
+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)
{
- return ZSTD_compress_generic_integral(cctx,
- output->dst, output->size, &output->pos,
- input->src, input->size, &input->pos,
- endOp);
+ ZSTD_outBuffer output = { dst, dstCapacity, *dstPos };
+ ZSTD_inBuffer input = { src, srcSize, *srcPos };
+
+ 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;
}
diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c
index ca5cd6a..b2c82e4 100644
--- a/lib/compress/zstdmt_compress.c
+++ b/lib/compress/zstdmt_compress.c
@@ -783,7 +783,8 @@
}
/* 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);
}
diff --git a/lib/zstd.h b/lib/zstd.h
index d4c24e7..1fc35fc 100644
--- a/lib/zstd.h
+++ b/lib/zstd.h
@@ -823,6 +823,20 @@
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 ---*/