summaryrefslogtreecommitdiff
path: root/extmod/moduzlib.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-06-13 12:37:49 +1000
committerDamien George <damien.p.george@gmail.com>2018-06-18 12:35:56 +1000
commite8398a58567cc94b866d46721fd06289601f5c8a (patch)
tree945e71ba803c72eb420b3b4d08c65cc647076027 /extmod/moduzlib.c
parent6abede2ca9e221b6aefcaccbda0c89e367507df1 (diff)
extmod: Update to use new mp_get_stream helper.
With this patch objects are only checked that they have the stream protocol at the start of their use as a stream, and afterwards the efficient mp_get_stream() helper is used to extract the stream protocol C methods.
Diffstat (limited to 'extmod/moduzlib.c')
-rw-r--r--extmod/moduzlib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c
index e9af07370..940b72805 100644
--- a/extmod/moduzlib.c
+++ b/extmod/moduzlib.c
@@ -53,7 +53,7 @@ STATIC unsigned char read_src_stream(TINF_DATA *data) {
p -= offsetof(mp_obj_decompio_t, decomp);
mp_obj_decompio_t *self = (mp_obj_decompio_t*)p;
- const mp_stream_p_t *stream = mp_get_stream_raise(self->src_stream, MP_STREAM_OP_READ);
+ const mp_stream_p_t *stream = mp_get_stream(self->src_stream);
int err;
byte c;
mp_uint_t out_sz = stream->read(self->src_stream, &c, 1, &err);
@@ -68,6 +68,7 @@ STATIC unsigned char read_src_stream(TINF_DATA *data) {
STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 1, 2, false);
+ mp_get_stream_raise(args[0], MP_STREAM_OP_READ);
mp_obj_decompio_t *o = m_new_obj(mp_obj_decompio_t);
o->base.type = type;
memset(&o->decomp, 0, sizeof(o->decomp));