File syn_lz4.c¶
FileList > src > syntropic > util > syn_lz4.c
Go to the source code of this file
Implementation of Zero-Heap LZ4 Raw Block Compression & Decompression.
#include "syn_lz4.h"#include <string.h>
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. |
Public Static Functions¶
| Type | Name |
|---|---|
| uint32_t | lz4_hash4 (uint32_t val) Hash 4 bytes into 12-bit hash index using Knuth multiplicative hash. |
| uint32_t | lz4_read32 (const uint8_t * ptr) Read 32-bit little-endian word from unaligned byte pointer. |
Macros¶
| Type | Name |
|---|---|
| define | LZ4_HASH_BITS 12U |
| define | LZ4_MIN_MATCH 4U |
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:
ctxPointer to initialized LZ4 context.srcSource data buffer to compress.src_sizeSource data size in bytes.dstDestination buffer for compressed output.dst_capacityCapacity 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.
Parameters:
input_sizeUncompressed payload size in bytes.
Returns:
Maximum compressed buffer size required.
function syn_lz4_decompress¶
Decompress LZ4 raw block buffer.
Decompression is fully stateless and requires no context workspace.
Parameters:
srcCompressed source buffer.src_sizeCompressed source size in bytes.dstDestination buffer for decompressed output.dst_capacityCapacity 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.
Parameters:
ctxPointer to LZ4 context instance.
Returns:
SYN_OK on success, or SYN_INVALID_PARAM.
Public Static Functions Documentation¶
function lz4_hash4¶
Hash 4 bytes into 12-bit hash index using Knuth multiplicative hash.
Parameters:
val32-bit integer word to hash.
Returns:
12-bit hash index (0..4095).
function lz4_read32¶
Read 32-bit little-endian word from unaligned byte pointer.
Parameters:
ptrPointer to byte stream.
Returns:
32-bit unsigned integer value.
Macro Definition Documentation¶
define LZ4_HASH_BITS¶
Log2 size of 4096-entry hash table
define LZ4_MIN_MATCH¶
Minimum byte match length for LZ4 compression
The documentation for this class was generated from the following file src/syntropic/util/syn_lz4.c