Function ZSTD_compressSequencesAndLiterals

Source
pub unsafe extern "C" fn ZSTD_compressSequencesAndLiterals(
    cctx: *mut ZSTD_CCtx,
    dst: *mut c_void,
    dstCapacity: usize,
    inSeqs: *const ZSTD_Sequence,
    nbSequences: usize,
    literals: *const c_void,
    litSize: usize,
    litBufCapacity: usize,
    decompressedSize: usize,
) -> usize
Expand description

ZSTD_compressSequencesAndLiterals() : This is a variant of ZSTD_compressSequences() which, instead of receiving (src,srcSize) as input parameter, receives (literals,litSize), aka all the literals, already extracted and laid out into a single continuous buffer. This can be useful if the process generating the sequences also happens to generate the buffer of literals, thus skipping an extraction + caching stage. It’s a speed optimization, useful when the right conditions are met, but it also features the following limitations:

  • Only supports explicit delimiter mode
  • Currently does not support Sequences validation (so input Sequences are trusted)
  • Not compatible with frame checksum, which must be disabled
  • If any block is incompressible, will fail and return an error
  • @litSize must be == sum of all @.litLength fields in @inSeqs. Any discrepancy will generate an error.
  • @litBufCapacity is the size of the underlying buffer into which literals are written, starting at address @literals. @litBufCapacity must be at least 8 bytes larger than @litSize.
  • @decompressedSize must be correct, and correspond to the sum of all Sequences. Any discrepancy will generate an error. @return : final compressed size, or a ZSTD error code.