all: Use mp_obj_malloc_with_finaliser everywhere it's applicable.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2024-02-16 11:02:58 +11:00
parent 4133c03040
commit cae690d047
19 changed files with 30 additions and 55 deletions

View File

@@ -131,8 +131,7 @@ STATIC mp_obj_t esp32_rmt_make_new(const mp_obj_type_t *type, size_t n_args, siz
mp_raise_ValueError(MP_ERROR_TEXT("clock_div must be between 1 and 255"));
}
esp32_rmt_obj_t *self = m_new_obj_with_finaliser(esp32_rmt_obj_t);
self->base.type = &esp32_rmt_type;
esp32_rmt_obj_t *self = mp_obj_malloc_with_finaliser(esp32_rmt_obj_t, &esp32_rmt_type);
self->channel_id = channel_id;
self->pin = pin_id;
self->clock_div = clock_div;

View File

@@ -405,8 +405,7 @@ STATIC machine_i2s_obj_t *mp_machine_i2s_make_new_instance(mp_int_t i2s_id) {
machine_i2s_obj_t *self;
if (MP_STATE_PORT(machine_i2s_obj)[i2s_id] == NULL) {
self = m_new_obj_with_finaliser(machine_i2s_obj_t);
self->base.type = &machine_i2s_type;
self = mp_obj_malloc_with_finaliser(machine_i2s_obj_t, &machine_i2s_type);
MP_STATE_PORT(machine_i2s_obj)[i2s_id] = self;
self->i2s_id = i2s_id;
} else {

View File

@@ -224,8 +224,7 @@ STATIC mp_obj_t machine_sdcard_make_new(const mp_obj_type_t *type, size_t n_args
DEBUG_printf(" Setting up host configuration");
sdcard_card_obj_t *self = m_new_obj_with_finaliser(sdcard_card_obj_t);
self->base.type = &machine_sdcard_type;
sdcard_card_obj_t *self = mp_obj_malloc_with_finaliser(sdcard_card_obj_t, &machine_sdcard_type);
self->flags = 0;
// Note that these defaults are macros that expand to structure
// constants so we can't directly assign them to fields.

View File

@@ -270,8 +270,7 @@ STATIC void _socket_getaddrinfo(const mp_obj_t addrtuple, struct addrinfo **resp
STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 0, 3, false);
socket_obj_t *sock = m_new_obj_with_finaliser(socket_obj_t);
sock->base.type = type_in;
socket_obj_t *sock = mp_obj_malloc_with_finaliser(socket_obj_t, type_in);
sock->domain = AF_INET;
sock->type = SOCK_STREAM;
sock->proto = 0;
@@ -364,8 +363,7 @@ STATIC mp_obj_t socket_accept(const mp_obj_t arg0) {
}
// create new socket object
socket_obj_t *sock = m_new_obj_with_finaliser(socket_obj_t);
sock->base.type = self->base.type;
socket_obj_t *sock = mp_obj_malloc_with_finaliser(socket_obj_t, self->base.type);
sock->fd = new_fd;
sock->domain = self->domain;
sock->type = self->type;

View File

@@ -87,9 +87,7 @@ static void ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx) {
STATIC mp_obj_t ppp_make_new(mp_obj_t stream) {
mp_get_stream_raise(stream, MP_STREAM_OP_READ | MP_STREAM_OP_WRITE);
ppp_if_obj_t *self = m_new_obj_with_finaliser(ppp_if_obj_t);
self->base.type = &ppp_if_type;
ppp_if_obj_t *self = mp_obj_malloc_with_finaliser(ppp_if_obj_t, &ppp_if_type);
self->stream = stream;
self->active = false;
self->connected = false;