Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
e9995bde
Commit
e9995bde
authored
Jan 28, 2015
by
Paul Sokolovsky
Browse files
moduzlib: Align out buffer to block size; shrink when decompression done.
parent
2324f3ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
extmod/moduzlib.c
View file @
e9995bde
...
...
@@ -63,8 +63,9 @@ STATIC mp_obj_t mod_uzlib_decompress(mp_uint_t n_args, const mp_obj_t *args) {
TINF_DATA
*
decomp
=
m_new_obj
(
TINF_DATA
);
DEBUG_printf
(
"sizeof(TINF_DATA)="
UINT_FMT
"
\n
"
,
sizeof
(
*
decomp
));
decomp
->
destStart
=
m_new
(
byte
,
bufinfo
.
len
);
decomp
->
destSize
=
bufinfo
.
len
;
decomp
->
destSize
=
(
bufinfo
.
len
+
15
)
&
~
15
;
decomp
->
destStart
=
m_new
(
byte
,
decomp
->
destSize
);
DEBUG_printf
(
"uzlib: Initial out buffer: "
UINT_FMT
" bytes
\n
"
,
decomp
->
destSize
);
decomp
->
destGrow
=
mod_uzlib_grow_buf
;
decomp
->
source
=
bufinfo
.
buf
;
...
...
@@ -78,7 +79,10 @@ STATIC mp_obj_t mod_uzlib_decompress(mp_uint_t n_args, const mp_obj_t *args) {
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_ValueError
,
MP_OBJ_NEW_SMALL_INT
(
st
)));
}
mp_obj_t
res
=
mp_obj_new_bytearray_by_ref
(
decomp
->
dest
-
decomp
->
destStart
,
decomp
->
destStart
);
mp_uint_t
final_sz
=
decomp
->
dest
-
decomp
->
destStart
;
DEBUG_printf
(
"uzlib: Resizing from "
UINT_FMT
" to final size: "
UINT_FMT
" bytes
\n
"
,
decomp
->
destSize
,
final_sz
);
decomp
->
destStart
=
(
byte
*
)
m_renew
(
byte
,
decomp
->
destStart
,
decomp
->
destSize
,
final_sz
);
mp_obj_t
res
=
mp_obj_new_bytearray_by_ref
(
final_sz
,
decomp
->
destStart
);
m_del_obj
(
TINF_DATA
,
decomp
);
return
res
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment