diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2022-04-22 17:09:15 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-05-03 22:28:14 +1000 |
commit | 0e7bfc88c6ac6b5d64240f91183a3cfe2ab67ade (patch) | |
tree | b578372082eb5b661263d61a1194af3868968cf9 /py/objgenerator.c | |
parent | 6a3bc0e1a1f4dc0ad0b71ca0f168ad1a87d28859 (diff) |
all: Use mp_obj_malloc everywhere it's applicable.
This replaces occurences of
foo_t *foo = m_new_obj(foo_t);
foo->base.type = &foo_type;
with
foo_t *foo = mp_obj_malloc(foo_t, &foo_type);
Excludes any places where base is a sub-field or when new0/memset is used.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/objgenerator.c')
-rw-r--r-- | py/objgenerator.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/py/objgenerator.c b/py/objgenerator.c index 850de3fb6..c1747a88b 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -59,9 +59,9 @@ 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 = m_new_obj_var(mp_obj_gen_instance_t, byte, - n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t)); - o->base.type = &mp_type_gen_instance; + mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, byte, + n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t), + &mp_type_gen_instance); o->pend_exc = mp_const_none; o->code_state.fun_bc = self_fun; @@ -106,8 +106,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_t *o = m_new_obj_var(mp_obj_gen_instance_t, byte, n_state * sizeof(mp_obj_t)); - o->base.type = &mp_type_gen_instance; + mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, 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; |