aboutsummaryrefslogtreecommitdiff
path: root/py/objtype.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-04-22 17:09:15 +1000
committerDamien George <damien@micropython.org>2022-05-03 22:28:14 +1000
commit0e7bfc88c6ac6b5d64240f91183a3cfe2ab67ade (patch)
treeb578372082eb5b661263d61a1194af3868968cf9 /py/objtype.c
parent6a3bc0e1a1f4dc0ad0b71ca0f168ad1a87d28859 (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/objtype.c')
-rw-r--r--py/objtype.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/py/objtype.c b/py/objtype.c
index e320adc8b..37c1e3bd2 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -99,8 +99,7 @@ STATIC
mp_obj_instance_t *mp_obj_new_instance(const mp_obj_type_t *class, const mp_obj_type_t **native_base) {
size_t num_native_bases = instance_count_native_bases(class, native_base);
assert(num_native_bases < 2);
- mp_obj_instance_t *o = m_new_obj_var(mp_obj_instance_t, mp_obj_t, num_native_bases);
- o->base.type = class;
+ mp_obj_instance_t *o = mp_obj_malloc_var(mp_obj_instance_t, mp_obj_t, num_native_bases, class);
mp_map_init(&o->members, 0);
// Initialise the native base-class slot (should be 1 at most) with a valid
// object. It doesn't matter which object, so long as it can be uniquely