diff options
| author | Paul Oliver <contact@pauloliver.dev> | 2026-04-14 23:31:04 +0200 |
|---|---|---|
| committer | Paul Oliver <contact@pauloliver.dev> | 2026-04-14 23:31:04 +0200 |
| commit | 9d08b9e61d48803d9c54a6921d573f974441ac42 (patch) | |
| tree | 5a24e494da413d6e0931543d32f44db57c0f3ebf /core/compress.c | |
| parent | 1fde30da093ecea7e32d39e5446fbde4d1fabd27 (diff) | |
Reorganizes C source files
Diffstat (limited to 'core/compress.c')
| -rw-r--r-- | core/compress.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/core/compress.c b/core/compress.c new file mode 100644 index 0000000..df61123 --- /dev/null +++ b/core/compress.c @@ -0,0 +1,56 @@ +void salis_deflate(z_stream *strm, size_t size, Bytef *in, Bytef *out) { + assert(strm); + assert(size); + assert(in); + assert(out); + + strm->zalloc = NULL; + strm->zfree = NULL; + strm->opaque = NULL; + + deflateInit(strm, Z_DEFAULT_COMPRESSION); + + strm->avail_in = size; + strm->avail_out = size; + strm->next_in = in; + strm->next_out = out; + + deflate(strm, Z_FINISH); +} + +void salis_deflate_end(z_stream *strm) { + assert(strm); + + deflateEnd(strm); +} + +void salis_inflate(z_stream *strm, size_t avail_in, size_t size, Bytef *in, Bytef *out) { + assert(strm); + assert(avail_in); + assert(size); + assert(in); + assert(out); + + strm->next_in = in; + strm->avail_in = avail_in; + strm->zalloc = NULL; + strm->zfree = NULL; + strm->opaque = NULL; + + inflateInit(strm); + + strm->avail_out = size; + strm->next_out = out; + +#if defined(NDEBUG) + inflate(strm, Z_FINISH); +#else + assert(inflate(strm, Z_FINISH)); +#endif +} + +void salis_inflate_end(z_stream *strm) { + assert(strm); + + inflateEnd(strm); +} |
