if (ZSTD_isError(errorCode)) return Z_MEM_ERROR; }
zwc->compressionLevel = level;
- strm->opaque = (voidpf) zwc;
+ strm->state = (struct internal_state*) zwc; /* use state which in not used by user */
strm->total_in = 0;
strm->total_out = 0;
return Z_OK;
if (!g_useZSTD)
return deflateSetDictionary(strm, dictionary, dictLength);
- { ZWRAP_CCtx* zwc = (ZWRAP_CCtx*) strm->opaque;
+ { ZWRAP_CCtx* zwc = (ZWRAP_CCtx*) strm->state;
LOG_WRAPPER("- deflateSetDictionary level=%d\n", (int)strm->data_type);
{ size_t const errorCode = ZBUFF_compressInitDictionary(zwc->zbc, dictionary, dictLength, zwc->compressionLevel);
if (ZSTD_isError(errorCode)) return Z_MEM_ERROR; }
return res;
}
- zwc = (ZWRAP_CCtx*) strm->opaque;
+ zwc = (ZWRAP_CCtx*) strm->state;
LOG_WRAPPER("deflate flush=%d avail_in=%d avail_out=%d total_in=%d total_out=%d\n", (int)flush, (int)strm->avail_in, (int)strm->avail_out, (int)strm->total_in, (int)strm->total_out);
if (strm->avail_in > 0) {
return deflateEnd(strm);
}
LOG_WRAPPER("- deflateEnd total_in=%d total_out=%d\n", (int)(strm->total_in), (int)(strm->total_out));
- { ZWRAP_CCtx* zwc = (ZWRAP_CCtx*) strm->opaque;
+ { ZWRAP_CCtx* zwc = (ZWRAP_CCtx*) strm->state;
size_t const errorCode = ZWRAP_freeCCtx(zwc);
if (ZSTD_isError(errorCode)) return Z_MEM_ERROR;
}
int stream_size;
char *version;
int windowBits;
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- voidpf opaque; /* private data object passed to zalloc and zfree */
} ZWRAP_DCtx;
zwd->stream_size = stream_size;
zwd->version = strdup(version);
- zwd->zalloc = strm->zalloc;
- zwd->zfree = strm->zfree;
- zwd->opaque = strm->opaque;
- strm->state = (struct internal_state*) zwd;
+ strm->state = (struct internal_state*) zwd; /* use state which in not used by user */
strm->total_in = 0;
strm->total_out = 0;
strm->reserved = 1; /* mark as unknown steam */
strm->avail_in = strm2.avail_in;
strm->next_out = strm2.next_out;
strm->avail_out = strm2.avail_out;
+
strm->reserved = 0; /* mark as zlib stream */
+ { size_t const errorCode = ZWRAP_freeDCtx(zwd);
+ if (ZSTD_isError(errorCode)) return Z_MEM_ERROR; }
+
if (flush == Z_INFLATE_SYNC) return inflateSync(strm);
return inflate(strm, flush);
}
{
int ret = Z_OK;
if (!strm->reserved)
- ret = inflateEnd(strm);
+ return inflateEnd(strm);
LOG_WRAPPER("- inflateEnd total_in=%d total_out=%d\n", (int)(strm->total_in), (int)(strm->total_out));
{ ZWRAP_DCtx* zwd = (ZWRAP_DCtx*) strm->state;