30static const char*
const s_tag =
"ra8_compress";
70 const uint32_t n = (uint32_t)len;
71 if (n > (c->
cap - c->
len)) {
111 uint32_t scratch_len,
112 const uint32_t* out_len)
162 const tdefl_status st = tdefl_compress_buffer(d, src, (
size_t)src_len, TDEFL_FINISH);
166 if (st != TDEFL_STATUS_DONE) {
178 uint32_t scratch_len,
185 tdefl_compressor* d = (tdefl_compressor*)scratch;
186 compress_ctx_t ctx = {.out = out, .cap = out_cap, .len = 0, .overflow = 0};
195 uint32_t scratch_len,
202 tdefl_compressor* d = (tdefl_compressor*)scratch;
203 compress_ctx_t ctx = {.out = out, .cap = out_cap, .len = 0, .overflow = 0};
204 const int flags = (int)TDEFL_DEFAULT_MAX_PROBES | (
int)TDEFL_WRITE_ZLIB_HEADER;
218 tinfl_decompress_mem_to_mem((
void*)out, (
size_t)out_cap, src, (
size_t)src_len, 0);
219 if (n == TINFL_DECOMPRESS_MEM_TO_MEM_FAILED) {
222 *out_len = (uint32_t)n;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
ra8_err_t ra8_decompress(const uint8_t *src, uint32_t src_len, uint8_t *out, uint32_t out_cap, uint32_t *out_len)
Raw-DEFLATE decompress src into out.
ra8_err_t ra8_compress_zlib(const uint8_t *src, uint32_t src_len, uint8_t *out, uint32_t out_cap, void *scratch, uint32_t scratch_len, uint32_t *out_len)
Zlib-wrap and DEFLATE-compress one bounded byte range.
static ra8_err_t internal_ra8_compress_validate(const uint8_t *src, const uint8_t *out, const void *scratch, uint32_t scratch_len, const uint32_t *out_len)
Validate ra8_compress arguments before driving the compressor.
static mz_bool internal_compress_put(const void *buf, int len, void *user)
tdefl put-buffer callback: append len bytes to the bounded output.
static ra8_err_t internal_ra8_compress_drive(tdefl_compressor *d, compress_ctx_t *ctx, const uint8_t *src, uint32_t src_len, int flags, uint32_t *out_len)
Drive the miniz tdefl engine over src into the bounded sink.
ra8_err_t ra8_compress(const uint8_t *src, uint32_t src_len, uint8_t *out, uint32_t out_cap, void *scratch, uint32_t scratch_len, uint32_t *out_len)
Raw-DEFLATE compress src into out.
App-domain DEFLATE compress / decompress (zero-heap, firmware-safe).
@ k_ra8_compress_scratch_bytes
Minimum compress scratch size (one miniz tdefl_compressor).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_fail
Generic unspecified failure.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
Bounded output sink for the tdefl put-buffer callback.
uint32_t len
Bytes written so far.
uint8_t * out
Destination buffer.
uint8_t overflow
Set when out filled up.
uint32_t cap
Destination capacity.