Update wrappers to use new gzip changes
This commit is contained in:
parent
36c0d81af8
commit
ae181d69af
@ -71,12 +71,12 @@
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t zlib_decompress(size_t n_args, const mp_obj_t *args) {
|
||||
bool is_zlib = true;
|
||||
if (n_args > 1 && MP_OBJ_SMALL_INT_VALUE(args[1]) < 0) {
|
||||
is_zlib = false;
|
||||
mp_int_t wbits = 0;
|
||||
if (n_args > 1) {
|
||||
wbits = MP_OBJ_SMALL_INT_VALUE(args[1]);
|
||||
}
|
||||
|
||||
return common_hal_zlib_decompress(args[0], is_zlib);
|
||||
return common_hal_zlib_decompress(args[0], wbits);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(zlib_decompress_obj, 1, 3, zlib_decompress);
|
||||
|
||||
|
@ -27,6 +27,6 @@
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ZLIB___INIT___H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ZLIB___INIT___H
|
||||
|
||||
mp_obj_t common_hal_zlib_decompress(mp_obj_t data, bool is_zlib);
|
||||
mp_obj_t common_hal_zlib_decompress(mp_obj_t data, mp_int_t wbits);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ZLIB___INIT___H
|
||||
|
@ -48,7 +48,7 @@
|
||||
#define DEBUG_printf(...) (void)0
|
||||
#endif
|
||||
|
||||
mp_obj_t common_hal_zlib_decompress(mp_obj_t data, bool is_zlib) {
|
||||
mp_obj_t common_hal_zlib_decompress(mp_obj_t data, mp_int_t wbits) {
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ);
|
||||
|
||||
@ -66,7 +66,12 @@ mp_obj_t common_hal_zlib_decompress(mp_obj_t data, bool is_zlib) {
|
||||
decomp->source_limit = (unsigned char *)bufinfo.buf + bufinfo.len;
|
||||
int st;
|
||||
|
||||
if (is_zlib) {
|
||||
if (wbits >= 16) {
|
||||
st = uzlib_gzip_parse_header(decomp);
|
||||
if (st < 0) {
|
||||
goto error;
|
||||
}
|
||||
} else if (wbits >= 0) {
|
||||
st = uzlib_zlib_parse_header(decomp);
|
||||
if (st < 0) {
|
||||
goto error;
|
||||
|
Loading…
Reference in New Issue
Block a user