-
In the process of using C to extend MicroPython, the construction method can be specified through make_new, but if the object is being destroyed, what should the destructor (or deinit) be specified through? Because during the process of constructing objects, malloc needs to be used to create some space, and when the object is destroyed, free release needs to be called |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@Mars-CN you need to use Look at e.g. |
Beta Was this translation helpful? Give feedback.
@Mars-CN you need to use
m_new_obj_with_finaliser
to construct the struct instance (so that the GC knows to call your finaliser), and then add a__del__
entry to your locals dict (this is your destructor/deinit method).Look at e.g.
extmod/modsocket.c
for an example.