8000 examples/usercmodule/cexample: Use mp_obj_malloc(). · peterwillcn/micropython@44ec57f · GitHub
[go: up one dir, main page]

Skip to content

Commit 44ec57f

Browse files
dlechdpgeorge
authored andcommitted
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>
1 parent fa8ebb1 commit 44ec57f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

examples/usercmodule/cexample/examplemodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(example_Timer_time_obj, example_Timer_time);
4343
// the user instantiates a Timer object.
4444
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) {
4545
// Allocates the new object and sets the type.
46-
example_Timer_obj_t *self = m_new_obj(example_Timer_obj_t);
47-
self->base.type = (mp_obj_type_t *)type;
46+
example_Timer_obj_t *self = mp_obj_malloc(example_Timer_obj_t, type);
4847

4948
// Initializes the time for this Timer instance.
5049
self->start_time = mp_hal_ticks_ms();

0 commit comments

Comments
 (0)
0