Skip to content

File syn_lz4.h

FileList > src > syntropic > util > syn_lz4.h

Go to the source code of this file

Zero-Heap LZ4 Raw Block Compression & Decompression. More...

  • #include "../common/syn_defs.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_Lz4
LZ4 Compression Workspace Context.

Public Functions

Type Name
size_t syn_lz4_compress (SYN_Lz4 * ctx, const void * src, size_t src_size, void * dst, size_t dst_capacity)
Compress data buffer into LZ4 raw block format.
size_t syn_lz4_compress_bound (size_t input_size)
Calculate worst-case compressed output bound for a given input size.
size_t syn_lz4_decompress (const void * src, size_t src_size, void * dst, size_t dst_capacity)
Decompress LZ4 raw block buffer.
SYN_Status syn_lz4_init (SYN_Lz4 * ctx)
Initialize an LZ4 compression context.

Macros

Type Name
define SYN_LZ4_HASH_SIZE 4096U

Detailed Description

Implements standard LZ4 raw block format compression and decompression without dynamic memory allocation or complex framing overhead.

Public Functions Documentation

function syn_lz4_compress

Compress data buffer into LZ4 raw block format.

size_t syn_lz4_compress (
    SYN_Lz4 * ctx,
    const void * src,
    size_t src_size,
    void * dst,
    size_t dst_capacity
) 

Parameters:

  • ctx Pointer to initialized LZ4 context.
  • src Source data buffer to compress.
  • src_size Source data size in bytes.
  • dst Destination buffer for compressed output.
  • dst_capacity Capacity of destination buffer in bytes.

Returns:

Number of compressed bytes written to dst, or 0 on error/overflow.


function syn_lz4_compress_bound

Calculate worst-case compressed output bound for a given input size.

size_t syn_lz4_compress_bound (
    size_t input_size
) 

Parameters:

  • input_size Uncompressed payload size in bytes.

Returns:

Maximum compressed buffer size required.


function syn_lz4_decompress

Decompress LZ4 raw block buffer.

size_t syn_lz4_decompress (
    const void * src,
    size_t src_size,
    void * dst,
    size_t dst_capacity
) 

Decompression is fully stateless and requires no context workspace.

Parameters:

  • src Compressed source buffer.
  • src_size Compressed source size in bytes.
  • dst Destination buffer for decompressed output.
  • dst_capacity Capacity of destination buffer in bytes.

Returns:

Number of decompressed bytes written to dst, or 0 on corruption/overflow.


function syn_lz4_init

Initialize an LZ4 compression context.

SYN_Status syn_lz4_init (
    SYN_Lz4 * ctx
) 

Parameters:

  • ctx Pointer to LZ4 context instance.

Returns:

SYN_OK on success, or SYN_INVALID_PARAM.


Macro Definition Documentation

define SYN_LZ4_HASH_SIZE

#define SYN_LZ4_HASH_SIZE `4096U`

LZ4 hash table size (4096 entries = 8 KB)



The documentation for this class was generated from the following file src/syntropic/util/syn_lz4.h