diff --git a/core/include/mbox.h b/core/include/mbox.h index 62a439271119..121b9ae65a59 100644 --- a/core/include/mbox.h +++ b/core/include/mbox.h @@ -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 diff --git a/pkg/lwip/include/arch/sys_arch.h b/pkg/lwip/include/arch/sys_arch.h index c9dda62357c0..64c38a3441a7 100644 --- a/pkg/lwip/include/arch/sys_arch.h +++ b/pkg/lwip/include/arch/sys_arch.h @@ -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); } }