Skip to content

Commit 50ba218

Browse files
committed
PulseIn, Counter: give finali(s/z)ers to these types too
for similar reasons, an interrupt handler might point at these objects, and we can worry less about it if the object deinits when it is GC'd.
1 parent c45db1c commit 50ba218

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

shared-bindings/countio/Counter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_arg
5757
const countio_edge_t edge = validate_edge(args[ARG_edge].u_obj, MP_QSTR_edge);
5858
const digitalio_pull_t pull = validate_pull(args[ARG_pull].u_obj, MP_QSTR_pull);
5959
// Make long-lived because some implementations use a pointer to the object as interrupt-handler data.
60-
countio_counter_obj_t *self = m_new_ll_obj(countio_counter_obj_t);
60+
countio_counter_obj_t *self = m_new_ll_obj_with_finaliser(countio_counter_obj_t);
6161
self->base.type = &countio_counter_type;
6262

6363
common_hal_countio_counter_construct(self, pin, edge, pull);
@@ -134,6 +134,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_reset_obj, countio_counter_reset);
134134
STATIC const mp_rom_map_elem_t countio_counter_locals_dict_table[] = {
135135
// Methods
136136
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&countio_counter_deinit_obj) },
137+
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&countio_counter_deinit_obj) },
137138
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
138139
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&countio_counter___exit___obj) },
139140
{ MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&countio_counter_count_obj) },

shared-bindings/pulseio/PulseIn.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg
8989
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj, MP_QSTR_pin);
9090

9191
// Make object long-lived to avoid moving between imports
92-
pulseio_pulsein_obj_t *self = m_new_ll_obj(pulseio_pulsein_obj_t);
92+
pulseio_pulsein_obj_t *self = m_new_ll_obj_with_finaliser(pulseio_pulsein_obj_t);
9393
self->base.type = &pulseio_pulsein_type;
9494

9595
common_hal_pulseio_pulsein_construct(self, pin, args[ARG_maxlen].u_int,
@@ -277,6 +277,7 @@ STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t va
277277
STATIC const mp_rom_map_elem_t pulseio_pulsein_locals_dict_table[] = {
278278
// Methods
279279
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&pulseio_pulsein_deinit_obj) },
280+
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&pulseio_pulsein_deinit_obj) },
280281
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
281282
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&pulseio_pulsein___exit___obj) },
282283
{ MP_ROM_QSTR(MP_QSTR_pause), MP_ROM_PTR(&pulseio_pulsein_pause_obj) },

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy