Lines Matching refs:zcs

2984 	ZSTD_CStream *zcs;  in ZSTD_createCStream_advanced()  local
2989 zcs = (ZSTD_CStream *)ZSTD_malloc(sizeof(ZSTD_CStream), customMem); in ZSTD_createCStream_advanced()
2990 if (zcs == NULL) in ZSTD_createCStream_advanced()
2992 memset(zcs, 0, sizeof(ZSTD_CStream)); in ZSTD_createCStream_advanced()
2993 memcpy(&zcs->customMem, &customMem, sizeof(ZSTD_customMem)); in ZSTD_createCStream_advanced()
2994 zcs->cctx = ZSTD_createCCtx_advanced(customMem); in ZSTD_createCStream_advanced()
2995 if (zcs->cctx == NULL) { in ZSTD_createCStream_advanced()
2996 ZSTD_freeCStream(zcs); in ZSTD_createCStream_advanced()
2999 return zcs; in ZSTD_createCStream_advanced()
3002 size_t ZSTD_freeCStream(ZSTD_CStream *zcs) in ZSTD_freeCStream() argument
3004 if (zcs == NULL) in ZSTD_freeCStream()
3007 ZSTD_customMem const cMem = zcs->customMem; in ZSTD_freeCStream()
3008 ZSTD_freeCCtx(zcs->cctx); in ZSTD_freeCStream()
3009 zcs->cctx = NULL; in ZSTD_freeCStream()
3010 ZSTD_freeCDict(zcs->cdictLocal); in ZSTD_freeCStream()
3011 zcs->cdictLocal = NULL; in ZSTD_freeCStream()
3012 ZSTD_free(zcs->inBuff, cMem); in ZSTD_freeCStream()
3013 zcs->inBuff = NULL; in ZSTD_freeCStream()
3014 ZSTD_free(zcs->outBuff, cMem); in ZSTD_freeCStream()
3015 zcs->outBuff = NULL; in ZSTD_freeCStream()
3016 ZSTD_free(zcs, cMem); in ZSTD_freeCStream()
3026 static size_t ZSTD_resetCStream_internal(ZSTD_CStream *zcs, unsigned long long pledgedSrcSize) in ZSTD_resetCStream_internal() argument
3028 if (zcs->inBuffSize == 0) in ZSTD_resetCStream_internal()
3031 if (zcs->cdict) in ZSTD_resetCStream_internal()
3032 CHECK_F(ZSTD_compressBegin_usingCDict(zcs->cctx, zcs->cdict, pledgedSrcSize)) in ZSTD_resetCStream_internal()
3034 CHECK_F(ZSTD_compressBegin_advanced(zcs->cctx, NULL, 0, zcs->params, pledgedSrcSize)); in ZSTD_resetCStream_internal()
3036 zcs->inToCompress = 0; in ZSTD_resetCStream_internal()
3037 zcs->inBuffPos = 0; in ZSTD_resetCStream_internal()
3038 zcs->inBuffTarget = zcs->blockSize; in ZSTD_resetCStream_internal()
3039 zcs->outBuffContentSize = zcs->outBuffFlushedSize = 0; in ZSTD_resetCStream_internal()
3040 zcs->stage = zcss_load; in ZSTD_resetCStream_internal()
3041 zcs->frameEnded = 0; in ZSTD_resetCStream_internal()
3042 zcs->pledgedSrcSize = pledgedSrcSize; in ZSTD_resetCStream_internal()
3043 zcs->inputProcessed = 0; in ZSTD_resetCStream_internal()
3047 size_t ZSTD_resetCStream(ZSTD_CStream *zcs, unsigned long long pledgedSrcSize) in ZSTD_resetCStream() argument
3050 zcs->params.fParams.contentSizeFlag = (pledgedSrcSize > 0); in ZSTD_resetCStream()
3052 return ZSTD_resetCStream_internal(zcs, pledgedSrcSize); in ZSTD_resetCStream()
3055 static size_t ZSTD_initCStream_advanced(ZSTD_CStream *zcs, const void *dict, size_t dictSize, ZSTD_… in ZSTD_initCStream_advanced() argument
3060 if (zcs->inBuffSize < neededInBuffSize) { in ZSTD_initCStream_advanced()
3061 zcs->inBuffSize = neededInBuffSize; in ZSTD_initCStream_advanced()
3062 ZSTD_free(zcs->inBuff, zcs->customMem); in ZSTD_initCStream_advanced()
3063 zcs->inBuff = (char *)ZSTD_malloc(neededInBuffSize, zcs->customMem); in ZSTD_initCStream_advanced()
3064 if (zcs->inBuff == NULL) in ZSTD_initCStream_advanced()
3067 zcs->blockSize = MIN(ZSTD_BLOCKSIZE_ABSOLUTEMAX, neededInBuffSize); in ZSTD_initCStream_advanced()
3069 if (zcs->outBuffSize < ZSTD_compressBound(zcs->blockSize) + 1) { in ZSTD_initCStream_advanced()
3070 zcs->outBuffSize = ZSTD_compressBound(zcs->blockSize) + 1; in ZSTD_initCStream_advanced()
3071 ZSTD_free(zcs->outBuff, zcs->customMem); in ZSTD_initCStream_advanced()
3072 zcs->outBuff = (char *)ZSTD_malloc(zcs->outBuffSize, zcs->customMem); in ZSTD_initCStream_advanced()
3073 if (zcs->outBuff == NULL) in ZSTD_initCStream_advanced()
3078 ZSTD_freeCDict(zcs->cdictLocal); in ZSTD_initCStream_advanced()
3079 zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize, 0, params, zcs->customMem); in ZSTD_initCStream_advanced()
3080 if (zcs->cdictLocal == NULL) in ZSTD_initCStream_advanced()
3082 zcs->cdict = zcs->cdictLocal; in ZSTD_initCStream_advanced()
3084 zcs->cdict = NULL; in ZSTD_initCStream_advanced()
3086 zcs->checksum = params.fParams.checksumFlag > 0; in ZSTD_initCStream_advanced()
3087 zcs->params = params; in ZSTD_initCStream_advanced()
3089 return ZSTD_resetCStream_internal(zcs, pledgedSrcSize); in ZSTD_initCStream_advanced()
3095 ZSTD_CStream *const zcs = ZSTD_createCStream_advanced(stackMem); in ZSTD_initCStream() local
3096 if (zcs) { in ZSTD_initCStream()
3097 size_t const code = ZSTD_initCStream_advanced(zcs, NULL, 0, params, pledgedSrcSize); in ZSTD_initCStream()
3102 return zcs; in ZSTD_initCStream()
3108 ZSTD_CStream *const zcs = ZSTD_initCStream(params, pledgedSrcSize, workspace, workspaceSize); in ZSTD_initCStream_usingCDict() local
3109 if (zcs) { in ZSTD_initCStream_usingCDict()
3110 zcs->cdict = cdict; in ZSTD_initCStream_usingCDict()
3111 if (ZSTD_isError(ZSTD_resetCStream_internal(zcs, pledgedSrcSize))) { in ZSTD_initCStream_usingCDict()
3115 return zcs; in ZSTD_initCStream_usingCDict()
3129 static size_t ZSTD_compressStream_generic(ZSTD_CStream *zcs, void *dst, size_t *dstCapacityPtr, con… in ZSTD_compressStream_generic() argument
3140 switch (zcs->stage) { in ZSTD_compressStream_generic()
3147 size_t const toLoad = zcs->inBuffTarget - zcs->inBuffPos; in ZSTD_compressStream_generic()
3148 size_t const loaded = ZSTD_limitCopy(zcs->inBuff + zcs->inBuffPos, toLoad, ip, iend - ip); in ZSTD_compressStream_generic()
3149 zcs->inBuffPos += loaded; in ZSTD_compressStream_generic()
3151 if ((zcs->inBuffPos == zcs->inToCompress) || (!flush && (toLoad != loaded))) { in ZSTD_compressStream_generic()
3160 size_t const iSize = zcs->inBuffPos - zcs->inToCompress; in ZSTD_compressStream_generic()
3165 cDst = zcs->outBuff, oSize = zcs->outBuffSize; in ZSTD_compressStream_generic()
3166 …cSize = (flush == zsf_end) ? ZSTD_compressEnd(zcs->cctx, cDst, oSize, zcs->inBuff + zcs->inToCompr… in ZSTD_compressStream_generic()
3167 : ZSTD_compressContinue(zcs->cctx, cDst, oSize, zcs->inBuff + zcs->inToCompress, iSize); in ZSTD_compressStream_generic()
3171 zcs->frameEnded = 1; in ZSTD_compressStream_generic()
3173 zcs->inBuffTarget = zcs->inBuffPos + zcs->blockSize; in ZSTD_compressStream_generic()
3174 if (zcs->inBuffTarget > zcs->inBuffSize) in ZSTD_compressStream_generic()
3175 zcs->inBuffPos = 0, zcs->inBuffTarget = zcs->blockSize; /* note : inBuffSize >= blockSize */ in ZSTD_compressStream_generic()
3176 zcs->inToCompress = zcs->inBuffPos; in ZSTD_compressStream_generic()
3181 zcs->outBuffContentSize = cSize; in ZSTD_compressStream_generic()
3182 zcs->outBuffFlushedSize = 0; in ZSTD_compressStream_generic()
3183 zcs->stage = zcss_flush; /* pass-through to flush stage */ in ZSTD_compressStream_generic()
3187 size_t const toFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize; in ZSTD_compressStream_generic()
3188 …size_t const flushed = ZSTD_limitCopy(op, oend - op, zcs->outBuff + zcs->outBuffFlushedSize, toFlu… in ZSTD_compressStream_generic()
3190 zcs->outBuffFlushedSize += flushed; in ZSTD_compressStream_generic()
3195 zcs->outBuffContentSize = zcs->outBuffFlushedSize = 0; in ZSTD_compressStream_generic()
3196 zcs->stage = zcss_load; in ZSTD_compressStream_generic()
3211 zcs->inputProcessed += *srcSizePtr; in ZSTD_compressStream_generic()
3212 if (zcs->frameEnded) in ZSTD_compressStream_generic()
3215 size_t hintInSize = zcs->inBuffTarget - zcs->inBuffPos; in ZSTD_compressStream_generic()
3217 hintInSize = zcs->blockSize; in ZSTD_compressStream_generic()
3222 size_t ZSTD_compressStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output, ZSTD_inBuffer *input) in ZSTD_compressStream() argument
3227 …ZSTD_compressStream_generic(zcs, (char *)(output->dst) + output->pos, &sizeWritten, (const char *)… in ZSTD_compressStream()
3237 size_t ZSTD_flushStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output) in ZSTD_flushStream() argument
3241 …size_t const result = ZSTD_compressStream_generic(zcs, (char *)(output->dst) + output->pos, &sizeW… in ZSTD_flushStream()
3247 return zcs->outBuffContentSize - zcs->outBuffFlushedSize; /* remaining to flush */ in ZSTD_flushStream()
3250 size_t ZSTD_endStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output) in ZSTD_endStream() argument
3256 if ((zcs->pledgedSrcSize) && (zcs->inputProcessed != zcs->pledgedSrcSize)) in ZSTD_endStream()
3259 if (zcs->stage != zcss_final) { in ZSTD_endStream()
3264 …ZSTD_compressStream_generic(zcs, ostart, &sizeWritten, &srcSize, &srcSize, zsf_end); /* use a vali… in ZSTD_endStream()
3265 size_t const remainingToFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize; in ZSTD_endStream()
3269 return remainingToFlush + ZSTD_BLOCKHEADERSIZE /* final empty block */ + (zcs->checksum * 4); in ZSTD_endStream()
3272 zcs->stage = zcss_final; in ZSTD_endStream()
3273zcs->outBuffContentSize = !notEnded ? 0 : ZSTD_compressEnd(zcs->cctx, zcs->outBuff, zcs->outBuffSi… in ZSTD_endStream()
3279 size_t const toFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize; in ZSTD_endStream()
3280 …size_t const flushed = ZSTD_limitCopy(op, oend - op, zcs->outBuff + zcs->outBuffFlushedSize, toFlu… in ZSTD_endStream()
3282 zcs->outBuffFlushedSize += flushed; in ZSTD_endStream()
3285 zcs->stage = zcss_init; /* end reached */ in ZSTD_endStream()