diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-02-26 20:02:14 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-03-04 08:44:56 -0500 |
commit | ce4620413b42e93db4c58449691eec113f0723b1 (patch) | |
tree | c96a5f61c9596b1e335ffce70893a13049e236ea /firmware/include/inflate.h | |
parent | fe4628fc3044bb2d21ee49f29ae1dba546db2453 (diff) | |
download | rockbox-ce4620413b42e93db4c58449691eec113f0723b1.tar.gz rockbox-ce4620413b42e93db4c58449691eec113f0723b1.zip |
inflate: Add helpers for using in-memory buffers
Using an in-memory buffer for the input or output data for 'inflate'
is likely to be extremely common and there's really only one way to
do it, so predefined helpers should be provided.
Change-Id: Ifd22e7b140a08e0e7dc05aec6b340dff5e2d9d0a
Diffstat (limited to 'firmware/include/inflate.h')
-rw-r--r-- | firmware/include/inflate.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/firmware/include/inflate.h b/firmware/include/inflate.h index b56ccf181a..7dae0448e3 100644 --- a/firmware/include/inflate.h +++ b/firmware/include/inflate.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #define _INFLATE_H_ | 23 | #define _INFLATE_H_ |
24 | 24 | ||
25 | #include <stdint.h> | 25 | #include <stdint.h> |
26 | #include <stddef.h> | ||
26 | 27 | ||
27 | enum { | 28 | enum { |
28 | INFLATE_RAW, | 29 | INFLATE_RAW, |
@@ -43,4 +44,18 @@ extern const uint32_t inflate_align; | |||
43 | // see above enum for possible options. | 44 | // see above enum for possible options. |
44 | int inflate(struct inflate* it, int st, inflate_reader read, void* rctx, inflate_writer write, void* wctx); | 45 | int inflate(struct inflate* it, int st, inflate_reader read, void* rctx, inflate_writer write, void* wctx); |
45 | 46 | ||
47 | struct inflate_bufferctx { | ||
48 | // initialize this with your input/output buffer. | ||
49 | // the pointer is updated as data is read or written. | ||
50 | void* buf; | ||
51 | |||
52 | // buffer end marker (= buf + buf_size). | ||
53 | void* end; | ||
54 | }; | ||
55 | |||
56 | // reader and writer for using an in-memory buffer. | ||
57 | // Use 'inflate_bufferctx' as the context argument. | ||
58 | uint32_t inflate_buffer_reader(void* block, uint32_t block_size, void* ctx); | ||
59 | uint32_t inflate_buffer_writer(const void* block, uint32_t block_size, void* ctx); | ||
60 | |||
46 | #endif | 61 | #endif |