forked from len0rd/rockbox
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
This commit is contained in:
parent
fe4628fc30
commit
ce4620413b
2 changed files with 40 additions and 0 deletions
|
@ -23,6 +23,7 @@
|
|||
#define _INFLATE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
enum {
|
||||
INFLATE_RAW,
|
||||
|
@ -43,4 +44,18 @@ extern const uint32_t inflate_align;
|
|||
// see above enum for possible options.
|
||||
int inflate(struct inflate* it, int st, inflate_reader read, void* rctx, inflate_writer write, void* wctx);
|
||||
|
||||
struct inflate_bufferctx {
|
||||
// initialize this with your input/output buffer.
|
||||
// the pointer is updated as data is read or written.
|
||||
void* buf;
|
||||
|
||||
// buffer end marker (= buf + buf_size).
|
||||
void* end;
|
||||
};
|
||||
|
||||
// reader and writer for using an in-memory buffer.
|
||||
// Use 'inflate_bufferctx' as the context argument.
|
||||
uint32_t inflate_buffer_reader(void* block, uint32_t block_size, void* ctx);
|
||||
uint32_t inflate_buffer_writer(const void* block, uint32_t block_size, void* ctx);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue