Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
LZ4: shortcuts to easy compress/decompress data

Functions

N_STRunzip4_nstr (N_STR *src)
 Return an uncompressed version of src produced by zip4_nstr.
 
N_STRzip4_nstr (N_STR *src)
 Return a compressed version of src using LZ4 block format.
 

Detailed Description

Function Documentation

◆ unzip4_nstr()

N_STR * unzip4_nstr ( N_STR src)

Return an uncompressed version of src produced by zip4_nstr.

Rejects payloads whose decoded-size header is absurdly large to stop a malicious sender from over-allocating. Returns NULL on error.

Return an uncompressed version of src produced by zip4_nstr.

Rejects inputs whose declared original size exceeds 256 MiB as a defence against malicious / corrupt frames causing a large allocation. Matches the same cap unzip_nstr uses.

Definition at line 107 of file n_lz4.c.

References __n_assert, N_STR::data, free_nstr, LOG_DEBUG, LOG_ERR, n_log, new_nstr(), and N_STR::written.

Referenced by netw_recv_func().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ zip4_nstr()

N_STR * zip4_nstr ( N_STR src)

Return a compressed version of src using LZ4 block format.

Self-framing, the output starts with a u32 (network byte order) carrying the original uncompressed length, followed by the lz4-compressed payload. Returns NULL on error.

Return a compressed version of src using LZ4 block format.

Self-framing, the produced N_STR begins with a u32 (network byte order) holding the original uncompressed length, followed by the LZ4-compressed bytes. Matches zip_nstr's framing so unzip{4,}_nstr can be selected per inbound packet without a separate framing header.

Definition at line 55 of file n_lz4.c.

References __n_assert, N_STR::data, free_nstr, N_STR::length, LOG_DEBUG, LOG_ERR, n_log, new_nstr(), and N_STR::written.

Referenced by netw_send_func().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: