I've declared the following type
Code: Select all
typedef struct _atiupy_can_message_obj_t {
mp_obj_base_t base;
mp_obj_t mp_obj_id;
mp_obj_list_t * mp_list_data;
mp_obj_dict_t * mp_dict_flags;
mp_obj_int_t * mp_int_timestamp;
} atiupy_mp_obj_can_message_t;
Code: Select all
msg1 = message()
In C-code, in the `.make_new`, I currently do
Code: Select all
atiupy_mp_obj_can_message_t * new_msg = m_new_obj(atiupy_mp_obj_can_message_t);
new_msg->mp_list_data = mp_obj_new_list(0, NULL);
new_msg->mp_dict_flags = mp_obj_new_dict(0);
new_msg->mp_int_timestamp = mp_obj_new_int_from_uint(pRcvMsg->timestamp);
as part of the struct (like a destructor of a class) . . .
Code: Select all
STATIC mp_obj_t can_message_del(mp_obj_t self_in)
{
atiupy_mp_obj_can_message_t * self_msg = self_in;
// self_msg->mp_obj_id is a small int so nothing to "free"
// free self_msg->mp_list_data
// free self_msg->mp_dict_flags
// free self_msg->mp_int_timestamp
return mp_const_none;
}
QUESTION
This leads me to believe that structs that only contain `mp_type*` objects do not actually need a finaliser.
Is this correct?
If yes, how do these other objects get freed?
If no, how do I free these other objects?