diff options
author | David Lechner <david@pybricks.com> | 2023-03-17 13:45:57 -0500 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-03-20 15:12:49 +1100 |
commit | 44ec57f13ac9fb998fd2dcf92b08a634a0c2bb3d (patch) | |
tree | 9597d608c0ea40616e525b6f555a8bb4da33c537 /examples/usercmodule/cexample/examplemodule.c | |
parent | fa8ebb1390549314485fc26e586573cff526807a (diff) | |
download | micropython-44ec57f13ac9fb998fd2dcf92b08a634a0c2bb3d.tar.gz micropython-44ec57f13ac9fb998fd2dcf92b08a634a0c2bb3d.zip |
examples/usercmodule/cexample: Use mp_obj_malloc().
Example code should use mp_obj_malloc() as well since people will
likely copy this code.
Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'examples/usercmodule/cexample/examplemodule.c')
-rw-r--r-- | examples/usercmodule/cexample/examplemodule.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/examples/usercmodule/cexample/examplemodule.c b/examples/usercmodule/cexample/examplemodule.c index b2457b2801..ccce03bcbd 100644 --- a/examples/usercmodule/cexample/examplemodule.c +++ b/examples/usercmodule/cexample/examplemodule.c @@ -43,8 +43,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(example_Timer_time_obj, example_Timer_time); // the user instantiates a Timer object. STATIC mp_obj_t example_Timer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { // Allocates the new object and sets the type. - example_Timer_obj_t *self = m_new_obj(example_Timer_obj_t); - self->base.type = (mp_obj_type_t *)type; + example_Timer_obj_t *self = mp_obj_malloc(example_Timer_obj_t, type); // Initializes the time for this Timer instance. self->start_time = mp_hal_ticks_ms(); |