Skip to content

Commit

Permalink
examples/usercmodule/cexample: Use mp_obj_malloc().
Browse files Browse the repository at this point in the history
Example code should use mp_obj_malloc() as well since people will
likely copy this code.

Signed-off-by: David Lechner <[email protected]>
  • Loading branch information
dlech authored and dpgeorge committed Mar 20, 2023
1 parent fa8ebb1 commit 44ec57f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions examples/usercmodule/cexample/examplemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 44ec57f

Please sign in to comment.