diff --git a/lib/uzlib/tinflate.c b/lib/uzlib/tinflate.c index 312485fd04..53536272f3 100644 --- a/lib/uzlib/tinflate.c +++ b/lib/uzlib/tinflate.c @@ -185,7 +185,7 @@ unsigned char uzlib_get_byte(uzlib_uncomp_t *d) read next byte using it. (Note: the callback can also update ->source and ->source_limit). */ if (d->source_read_cb && !d->eof) { - int val = d->source_read_cb(d); + int val = d->source_read_cb(d->source_read_data); if (val >= 0) { return (unsigned char)val; } diff --git a/lib/uzlib/uzlib.h b/lib/uzlib/uzlib.h index 030f7698c1..16984a77d3 100644 --- a/lib/uzlib/uzlib.h +++ b/lib/uzlib/uzlib.h @@ -84,7 +84,8 @@ typedef struct _uzlib_uncomp_t { also return -1 in case of EOF (or irrecoverable error). Note that besides returning the next byte, it may also update source and source_limit fields, thus allowing for buffered operation. */ - int (*source_read_cb)(struct _uzlib_uncomp_t *uncomp); + void *source_read_data; + int (*source_read_cb)(void *); unsigned int tag; unsigned int bitcount; diff --git a/ports/stm32/mboot/gzstream.c b/ports/stm32/mboot/gzstream.c index 764ef0a477..f8b0987edf 100644 --- a/ports/stm32/mboot/gzstream.c +++ b/ports/stm32/mboot/gzstream.c @@ -45,7 +45,8 @@ typedef struct _gz_stream_t { static gz_stream_t gz_stream SECTION_NOZERO_BSS; -static int gz_stream_read_src(uzlib_uncomp_t *decomp) { +static int gz_stream_read_src(void *data) { + uzlib_uncomp_t *decomp = data; int n = gz_stream.stream_read(gz_stream.stream_data, gz_stream.buf, sizeof(gz_stream.buf)); if (n < 0) { // Stream error @@ -76,6 +77,7 @@ int gz_stream_init_from_stream(void *stream_data, stream_read_t stream_read) { gz_stream.stream_read = stream_read; memset(&gz_stream.decomp, 0, sizeof(gz_stream.decomp)); + gz_stream.decomp.source_read_data = &gz_stream.decomp; gz_stream.decomp.source_read_cb = gz_stream_read_src; int header_wbits;