Skip to content
Discussion options

You must be logged in to vote

I was wondering about proper destruction of k_mutex and k_sem objects. In both these APIs there are init functions, but no destroy functions.

The xxx_init() function assumes that the object is "already created", that is the pointer passed refer to a valid memory area that contains the underlying data structure.
If you are using dynamic memory, you can therefore dispose the objects by simply freeing the memory. This assumes, of course, that it is safe to do so, like the mutex is unlocked and no thread will use this mutex once destroyed.

Regarding your comment about the double-linked list used for tracking. The one that is problematic is related to the object core subsystem, which is used…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pfayolle
Comment options

Answer selected by pfayolle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants