From: Yann Collet Date: Wed, 28 Dec 2016 16:08:28 +0000 (+0100) Subject: compression threads use ZSTD_compressCCtx() X-Git-Tag: v1.1.3^2~19^2~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c0ed9483aab0b0d95e593723f2ef0bdd55160e7;p=thirdparty%2Fzstd.git compression threads use ZSTD_compressCCtx() --- diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index c698dce0e..0f14dbf31 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -235,13 +235,16 @@ struct ZSTDMT_CCtx_s { static void* ZSTDMT_compressionThread(void* arg) { if (arg==NULL) return NULL; /* error : should not be possible */ - ZSTDMT_CCtx* const cctx = (ZSTDMT_CCtx*) arg; - ZSTDMT_jobAgency* const jobAgency = &cctx->jobAgency; - ZSTDMT_bufferPool* const pool = &cctx->bufferPool; + ZSTDMT_CCtx* const mtctx = (ZSTDMT_CCtx*) arg; + ZSTDMT_jobAgency* const jobAgency = &mtctx->jobAgency; + ZSTDMT_bufferPool* const pool = &mtctx->bufferPool; + ZSTD_CCtx* const cctx = ZSTD_createCCtx(); + if (cctx==NULL) return NULL; /* allocation failure : thread not started */ for (;;) { ZSTDMT_jobDescription const job = ZSTDMT_getjob(jobAgency); if (job.src == NULL) { - DEBUGLOG(4, "thread exit ") + DEBUGLOG(4, "thread exit "); + ZSTD_freeCCtx(cctx); return NULL; } ZSTDMT_dstBufferManager* dstBufferManager = job.dstManager; @@ -249,7 +252,8 @@ static void* ZSTDMT_compressionThread(void* arg) DEBUGLOG(4, "requesting a dstBuffer for frame %u", job.frameNumber); buffer_t const dstBuffer = job.frameNumber ? ZSTDMT_getBuffer(pool, dstBufferCapacity) : ZSTDMT_getDstBuffer(dstBufferManager); /* lack params */ DEBUGLOG(4, "start compressing frame %u", job.frameNumber); - size_t const cSize = ZSTD_compress(dstBuffer.start, dstBuffer.bufferSize, job.src, job.srcSize, job.compressionLevel); + //size_t const cSize = ZSTD_compress(dstBuffer.start, dstBuffer.bufferSize, job.src, job.srcSize, job.compressionLevel); + size_t const cSize = ZSTD_compressCCtx(cctx, dstBuffer.start, dstBuffer.bufferSize, job.src, job.srcSize, job.compressionLevel); if (ZSTD_isError(cSize)) return (void*)(cSize); /* error */ size_t const writeError = ZSTDMT_tryWriteFrame(dstBufferManager, dstBuffer.start, cSize, job.frameNumber, job.isLastFrame); /* pas clair */ if (ZSTD_isError(writeError)) return (void*)writeError;