diff options
| author | Damien George <damien@micropython.org> | 2024-02-16 11:41:28 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-02-19 23:40:54 +1100 |
| commit | 24234937747e6d7fd920d21358fb26b826398e1a (patch) | |
| tree | 7f6662dc0889b5a1c051fc1b12cb7c8077584fd3 /py/objgenerator.c | |
| parent | 9242e3d16d34dd15f1cd868681be45432b443c5a (diff) | |
py/obj: Change sizeof to offsetof in mp_obj_malloc_var macro.
Following b6a977848407a4ced45d118cf926bd915cc89dfb, to properly calculate
the size of the variable-length allocation.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/objgenerator.c')
| -rw-r--r-- | py/objgenerator.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objgenerator.c b/py/objgenerator.c index ecd1f583e..7786b1fc8 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -59,7 +59,7 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons MP_BC_PRELUDE_SIG_DECODE(ip); // allocate the generator object, with room for local stack and exception stack - mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, byte, + mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, code_state.state, byte, n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t), &mp_type_gen_instance); @@ -114,7 +114,7 @@ STATIC mp_obj_t native_gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_k MP_BC_PRELUDE_SIG_DECODE(ip); // Allocate the generator object, with room for local stack (exception stack not needed). - mp_obj_gen_instance_native_t *o = mp_obj_malloc_var(mp_obj_gen_instance_native_t, byte, n_state * sizeof(mp_obj_t), &mp_type_gen_instance); + mp_obj_gen_instance_native_t *o = mp_obj_malloc_var(mp_obj_gen_instance_native_t, code_state.state, byte, n_state * sizeof(mp_obj_t), &mp_type_gen_instance); // Parse the input arguments and set up the code state o->pend_exc = mp_const_none; |
