18 #include <stddef.h> /* size_t */ |
18 #include <stddef.h> /* size_t */ |
19 |
19 |
20 |
20 |
21 /* ===== ZSTDLIB_API : control library symbols visibility ===== */ |
21 /* ===== ZSTDLIB_API : control library symbols visibility ===== */ |
22 #if defined(__GNUC__) && (__GNUC__ >= 4) |
22 #if defined(__GNUC__) && (__GNUC__ >= 4) |
23 # define ZSTDLIB_API __attribute__ ((visibility ("default"))) |
23 # define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default"))) |
24 #elif defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) |
24 #else |
25 # define ZSTDLIB_API __declspec(dllexport) |
25 # define ZSTDLIB_VISIBILITY |
|
26 #endif |
|
27 #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) |
|
28 # define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBILITY |
26 #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) |
29 #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) |
27 # define ZSTDLIB_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ |
30 # define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ |
28 #else |
31 #else |
29 # define ZSTDLIB_API |
32 # define ZSTDLIB_API ZSTDLIB_VISIBILITY |
30 #endif |
33 #endif |
31 |
34 |
32 |
35 |
33 /******************************************************************************************************* |
36 /******************************************************************************************************* |
34 Introduction |
37 Introduction |
51 *********************************************************************************************************/ |
54 *********************************************************************************************************/ |
52 |
55 |
53 /*------ Version ------*/ |
56 /*------ Version ------*/ |
54 #define ZSTD_VERSION_MAJOR 1 |
57 #define ZSTD_VERSION_MAJOR 1 |
55 #define ZSTD_VERSION_MINOR 1 |
58 #define ZSTD_VERSION_MINOR 1 |
56 #define ZSTD_VERSION_RELEASE 2 |
59 #define ZSTD_VERSION_RELEASE 3 |
57 |
60 |
58 #define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE |
61 #define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE |
59 #define ZSTD_QUOTE(str) #str |
62 #define ZSTD_QUOTE(str) #str |
60 #define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str) |
63 #define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str) |
61 #define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION) |
64 #define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION) |
168 |
171 |
169 /*! ZSTD_createCDict() : |
172 /*! ZSTD_createCDict() : |
170 * When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once. |
173 * When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once. |
171 * ZSTD_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay. |
174 * ZSTD_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay. |
172 * ZSTD_CDict can be created once and used by multiple threads concurrently, as its usage is read-only. |
175 * ZSTD_CDict can be created once and used by multiple threads concurrently, as its usage is read-only. |
173 * `dict` can be released after ZSTD_CDict creation. */ |
176 * `dictBuffer` can be released after ZSTD_CDict creation, as its content is copied within CDict */ |
174 ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dict, size_t dictSize, int compressionLevel); |
177 ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize, int compressionLevel); |
175 |
178 |
176 /*! ZSTD_freeCDict() : |
179 /*! ZSTD_freeCDict() : |
177 * Function frees memory allocated by ZSTD_createCDict(). */ |
180 * Function frees memory allocated by ZSTD_createCDict(). */ |
178 ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict); |
181 ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict); |
179 |
182 |
189 |
192 |
190 typedef struct ZSTD_DDict_s ZSTD_DDict; |
193 typedef struct ZSTD_DDict_s ZSTD_DDict; |
191 |
194 |
192 /*! ZSTD_createDDict() : |
195 /*! ZSTD_createDDict() : |
193 * Create a digested dictionary, ready to start decompression operation without startup delay. |
196 * Create a digested dictionary, ready to start decompression operation without startup delay. |
194 * `dict` can be released after creation. */ |
197 * dictBuffer can be released after DDict creation, as its content is copied inside DDict */ |
195 ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dict, size_t dictSize); |
198 ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize); |
196 |
199 |
197 /*! ZSTD_freeDDict() : |
200 /*! ZSTD_freeDDict() : |
198 * Function frees memory allocated with ZSTD_createDDict() */ |
201 * Function frees memory allocated with ZSTD_createDDict() */ |
199 ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict); |
202 ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict); |
200 |
203 |
323 * They are provided for advanced usages. |
326 * They are provided for advanced usages. |
324 * Use them only in association with static linking. |
327 * Use them only in association with static linking. |
325 * ***************************************************************************************/ |
328 * ***************************************************************************************/ |
326 |
329 |
327 /* --- Constants ---*/ |
330 /* --- Constants ---*/ |
328 #define ZSTD_MAGICNUMBER 0xFD2FB528 /* v0.8 */ |
331 #define ZSTD_MAGICNUMBER 0xFD2FB528 /* >= v0.8.0 */ |
329 #define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50U |
332 #define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50U |
330 |
333 |
331 #define ZSTD_WINDOWLOG_MAX_32 25 |
334 #define ZSTD_WINDOWLOG_MAX_32 25 |
332 #define ZSTD_WINDOWLOG_MAX_64 27 |
335 #define ZSTD_WINDOWLOG_MAX_64 27 |
333 #define ZSTD_WINDOWLOG_MAX ((U32)(MEM_32bits() ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64)) |
336 #define ZSTD_WINDOWLOG_MAX ((U32)(MEM_32bits() ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64)) |
343 #define ZSTD_SEARCHLENGTH_MIN 3 /* only for ZSTD_btopt, other strategies are limited to 4 */ |
346 #define ZSTD_SEARCHLENGTH_MIN 3 /* only for ZSTD_btopt, other strategies are limited to 4 */ |
344 #define ZSTD_TARGETLENGTH_MIN 4 |
347 #define ZSTD_TARGETLENGTH_MIN 4 |
345 #define ZSTD_TARGETLENGTH_MAX 999 |
348 #define ZSTD_TARGETLENGTH_MAX 999 |
346 |
349 |
347 #define ZSTD_FRAMEHEADERSIZE_MAX 18 /* for static allocation */ |
350 #define ZSTD_FRAMEHEADERSIZE_MAX 18 /* for static allocation */ |
|
351 #define ZSTD_FRAMEHEADERSIZE_MIN 6 |
348 static const size_t ZSTD_frameHeaderSize_prefix = 5; |
352 static const size_t ZSTD_frameHeaderSize_prefix = 5; |
349 static const size_t ZSTD_frameHeaderSize_min = 6; |
353 static const size_t ZSTD_frameHeaderSize_min = ZSTD_FRAMEHEADERSIZE_MIN; |
350 static const size_t ZSTD_frameHeaderSize_max = ZSTD_FRAMEHEADERSIZE_MAX; |
354 static const size_t ZSTD_frameHeaderSize_max = ZSTD_FRAMEHEADERSIZE_MAX; |
351 static const size_t ZSTD_skippableHeaderSize = 8; /* magic number + skippable frame length */ |
355 static const size_t ZSTD_skippableHeaderSize = 8; /* magic number + skippable frame length */ |
352 |
356 |
353 |
357 |
354 /*--- Advanced types ---*/ |
358 /*--- Advanced types ---*/ |
363 unsigned targetLength; /**< acceptable match size for optimal parser (only) : larger == more compression, slower */ |
367 unsigned targetLength; /**< acceptable match size for optimal parser (only) : larger == more compression, slower */ |
364 ZSTD_strategy strategy; |
368 ZSTD_strategy strategy; |
365 } ZSTD_compressionParameters; |
369 } ZSTD_compressionParameters; |
366 |
370 |
367 typedef struct { |
371 typedef struct { |
368 unsigned contentSizeFlag; /**< 1: content size will be in frame header (if known). */ |
372 unsigned contentSizeFlag; /**< 1: content size will be in frame header (when known) */ |
369 unsigned checksumFlag; /**< 1: will generate a 22-bits checksum at end of frame, to be used for error detection by decompressor */ |
373 unsigned checksumFlag; /**< 1: generate a 32-bits checksum at end of frame, for error detection */ |
370 unsigned noDictIDFlag; /**< 1: no dict ID will be saved into frame header (if dictionary compression) */ |
374 unsigned noDictIDFlag; /**< 1: no dictID will be saved into frame header (if dictionary compression) */ |
371 } ZSTD_frameParameters; |
375 } ZSTD_frameParameters; |
372 |
376 |
373 typedef struct { |
377 typedef struct { |
374 ZSTD_compressionParameters cParams; |
378 ZSTD_compressionParameters cParams; |
375 ZSTD_frameParameters fParams; |
379 ZSTD_frameParameters fParams; |
395 |
399 |
396 /*! ZSTD_sizeofCCtx() : |
400 /*! ZSTD_sizeofCCtx() : |
397 * Gives the amount of memory used by a given ZSTD_CCtx */ |
401 * Gives the amount of memory used by a given ZSTD_CCtx */ |
398 ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx); |
402 ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx); |
399 |
403 |
|
404 typedef enum { |
|
405 ZSTD_p_forceWindow /* Force back-references to remain < windowSize, even when referencing Dictionary content (default:0)*/ |
|
406 } ZSTD_CCtxParameter; |
|
407 /*! ZSTD_setCCtxParameter() : |
|
408 * Set advanced parameters, selected through enum ZSTD_CCtxParameter |
|
409 * @result : 0, or an error code (which can be tested with ZSTD_isError()) */ |
|
410 ZSTDLIB_API size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned value); |
|
411 |
|
412 /*! ZSTD_createCDict_byReference() : |
|
413 * Create a digested dictionary for compression |
|
414 * Dictionary content is simply referenced, and therefore stays in dictBuffer. |
|
415 * It is important that dictBuffer outlives CDict, it must remain read accessible throughout the lifetime of CDict */ |
|
416 ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel); |
|
417 |
400 /*! ZSTD_createCDict_advanced() : |
418 /*! ZSTD_createCDict_advanced() : |
401 * Create a ZSTD_CDict using external alloc and free, and customized compression parameters */ |
419 * Create a ZSTD_CDict using external alloc and free, and customized compression parameters */ |
402 ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize, |
420 ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize, unsigned byReference, |
403 ZSTD_parameters params, ZSTD_customMem customMem); |
421 ZSTD_parameters params, ZSTD_customMem customMem); |
404 |
422 |
405 /*! ZSTD_sizeof_CDict() : |
423 /*! ZSTD_sizeof_CDict() : |
406 * Gives the amount of memory used by a given ZSTD_sizeof_CDict */ |
424 * Gives the amount of memory used by a given ZSTD_sizeof_CDict */ |
407 ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict); |
425 ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict); |
453 |
471 |
454 /*! ZSTD_sizeof_DCtx() : |
472 /*! ZSTD_sizeof_DCtx() : |
455 * Gives the amount of memory used by a given ZSTD_DCtx */ |
473 * Gives the amount of memory used by a given ZSTD_DCtx */ |
456 ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx); |
474 ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx); |
457 |
475 |
|
476 /*! ZSTD_createDDict_byReference() : |
|
477 * Create a digested dictionary, ready to start decompression operation without startup delay. |
|
478 * Dictionary content is simply referenced, and therefore stays in dictBuffer. |
|
479 * It is important that dictBuffer outlives DDict, it must remain read accessible throughout the lifetime of DDict */ |
|
480 ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize); |
|
481 |
|
482 ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize, |
|
483 unsigned byReference, ZSTD_customMem customMem); |
|
484 |
458 /*! ZSTD_sizeof_DDict() : |
485 /*! ZSTD_sizeof_DDict() : |
459 * Gives the amount of memory used by a given ZSTD_DDict */ |
486 * Gives the amount of memory used by a given ZSTD_DDict */ |
460 ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); |
487 ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); |
461 |
488 |
462 /*! ZSTD_getDictID_fromDict() : |
489 /*! ZSTD_getDictID_fromDict() : |
463 * Provides the dictID stored within dictionary. |
490 * Provides the dictID stored within dictionary. |
464 * if @return == 0, the dictionary is not conformant with Zstandard specification. |
491 * if @return == 0, the dictionary is not conformant with Zstandard specification. |
465 * It can still be loaded, but as a content-only dictionary. */ |
492 * It can still be loaded, but as a content-only dictionary. */ |
466 unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize); |
493 ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize); |
467 |
494 |
468 /*! ZSTD_getDictID_fromDDict() : |
495 /*! ZSTD_getDictID_fromDDict() : |
469 * Provides the dictID of the dictionary loaded into `ddict`. |
496 * Provides the dictID of the dictionary loaded into `ddict`. |
470 * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. |
497 * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. |
471 * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ |
498 * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ |
472 unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict); |
499 ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict); |
473 |
500 |
474 /*! ZSTD_getDictID_fromFrame() : |
501 /*! ZSTD_getDictID_fromFrame() : |
475 * Provides the dictID required to decompressed the frame stored within `src`. |
502 * Provides the dictID required to decompressed the frame stored within `src`. |
476 * If @return == 0, the dictID could not be decoded. |
503 * If @return == 0, the dictID could not be decoded. |
477 * This could for one of the following reasons : |
504 * This could for one of the following reasons : |
479 * - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden information. |
506 * - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden information. |
480 * Note : this use case also happens when using a non-conformant dictionary. |
507 * Note : this use case also happens when using a non-conformant dictionary. |
481 * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`). |
508 * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`). |
482 * - This is not a Zstandard frame. |
509 * - This is not a Zstandard frame. |
483 * When identifying the exact failure cause, it's possible to used ZSTD_getFrameParams(), which will provide a more precise error code. */ |
510 * When identifying the exact failure cause, it's possible to used ZSTD_getFrameParams(), which will provide a more precise error code. */ |
484 unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize); |
511 ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize); |
485 |
512 |
486 |
513 |
487 /******************************************************************** |
514 /******************************************************************** |
488 * Advanced streaming functions |
515 * Advanced streaming functions |
489 ********************************************************************/ |
516 ********************************************************************/ |
490 |
517 |
491 /*===== Advanced Streaming compression functions =====*/ |
518 /*===== Advanced Streaming compression functions =====*/ |
492 ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem); |
519 ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem); |
493 ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct */ |
520 ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct */ |
494 ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); |
521 ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); /**< note: a dict will not be used if dict == NULL or dictSize < 8 */ |
495 ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize, |
522 ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize, |
496 ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be zero == unknown */ |
523 ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be zero == unknown */ |
497 ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */ |
524 ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */ |
498 ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); /**< re-use compression parameters from previous init; skip dictionary loading stage; zcs must be init at least once before */ |
525 ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); /**< re-use compression parameters from previous init; skip dictionary loading stage; zcs must be init at least once before */ |
499 ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs); |
526 ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs); |
500 |
527 |
501 |
528 |
502 /*===== Advanced Streaming decompression functions =====*/ |
529 /*===== Advanced Streaming decompression functions =====*/ |
503 typedef enum { ZSTDdsp_maxWindowSize } ZSTD_DStreamParameter_e; |
530 typedef enum { DStream_p_maxWindowSize } ZSTD_DStreamParameter_e; |
504 ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem); |
531 ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem); |
505 ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); |
532 ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); /**< note: a dict will not be used if dict == NULL or dictSize < 8 */ |
506 ZSTDLIB_API size_t ZSTD_setDStreamParameter(ZSTD_DStream* zds, ZSTD_DStreamParameter_e paramType, unsigned paramValue); |
533 ZSTDLIB_API size_t ZSTD_setDStreamParameter(ZSTD_DStream* zds, ZSTD_DStreamParameter_e paramType, unsigned paramValue); |
507 ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict); /**< note : ddict will just be referenced, and must outlive decompression session */ |
534 ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict); /**< note : ddict will just be referenced, and must outlive decompression session */ |
508 ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompression parameters from previous init; saves dictionary loading */ |
535 ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompression parameters from previous init; saves dictionary loading */ |
509 ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds); |
536 ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds); |
510 |
537 |
540 It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks) |
567 It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks) |
541 - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps. |
568 - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps. |
542 In which case, it will "discard" the relevant memory section from its history. |
569 In which case, it will "discard" the relevant memory section from its history. |
543 |
570 |
544 Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum. |
571 Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum. |
545 It's possible to use a NULL,0 src content, in which case, it will write a final empty block to end the frame, |
572 It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame. |
546 Without last block mark, frames will be considered unfinished (broken) by decoders. |
573 Without last block mark, frames will be considered unfinished (corrupted) by decoders. |
547 |
574 |
548 You can then reuse `ZSTD_CCtx` (ZSTD_compressBegin()) to compress some new frame. |
575 `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress some new frame. |
549 */ |
576 */ |
550 |
577 |
551 /*===== Buffer-less streaming compression functions =====*/ |
578 /*===== Buffer-less streaming compression functions =====*/ |
552 ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel); |
579 ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel); |
553 ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel); |
580 ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel); |
554 ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); |
581 ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); |
555 ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); |
582 ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); |
|
583 ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict, unsigned long long pledgedSrcSize); |
556 ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); |
584 ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); |
557 ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); |
585 ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); |
558 |
586 |
559 |
587 |
560 |
588 |