1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

Merge pull request #15485 from miri64/mbox/enh/mbox-unset

mbox: provide function to unset initialized mbox
This commit is contained in:
Teufelchen 2024-03-19 13:23:22 +00:00 committed by GitHub
commit 52425330a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -185,6 +185,17 @@ static inline size_t mbox_avail(mbox_t *mbox)
return cib_avail(&mbox->cib);
}
/**
* @brief Unset's the mbox, effectively deinitializing and invalidating it.
*
* @param[in] mbox ptr to mailbox to operate on
*/
static inline void mbox_unset(mbox_t *mbox)
{
mbox->msg_array = NULL;
mbox->cib.mask = 0;
}
#ifdef __cplusplus
}
#endif

View File

@ -101,13 +101,13 @@ typedef struct {
static inline bool sys_mbox_valid(sys_mbox_t *mbox)
{
return (mbox != NULL) && (mbox->mbox.cib.mask != 0);
return (mbox != NULL) && (mbox_size(&mbox->mbox) != 0);
}
static inline void sys_mbox_set_invalid(sys_mbox_t *mbox)
{
if (mbox != NULL) {
mbox->mbox.cib.mask = 0;
mbox_unset(&mbox->mbox);
}
}