@@ -38,6 +38,7 @@ extern "C" {
3838#include "list.h"
3939#include "smp.h"
4040#include "term_typedef.h"
41+ #include "utils.h"
4142
4243struct Context ;
4344
@@ -273,16 +274,6 @@ bool mailbox_peek(Context *ctx, term *out);
273274 */
274275MailboxMessage * mailbox_take_message (Mailbox * mbox );
275276
276- /**
277- * @brief Remove next message from mailbox.
278- *
279- * @details Discard a term that has been previously queued on a certain process
280- * or driver mailbox. To be called from the process only. Term messages are
281- * actually added as fragments to the heap and will be gone at next GC.
282- * @param mbx the mailbox to remove next message from.
283- */
284- void mailbox_remove_message (Mailbox * mbox , Heap * ctx );
285-
286277/**
287278 * @brief Get first message from mailbox.
288279 *
@@ -314,6 +305,22 @@ void mailbox_destroy(Mailbox *mbox, Heap *heap);
314305 */
315306void mailbox_message_dispose (MailboxMessage * m , Heap * heap );
316307
308+ /**
309+ * @brief Remove next message from mailbox.
310+ *
311+ * @details Discard a term that has been previously queued on a certain process
312+ * or driver mailbox. To be called from the process only. Term messages are
313+ * actually added as fragments to the heap and will be gone at next GC.
314+ * @param mbx the mailbox to remove next message from.
315+ */
316+ static inline void mailbox_remove_message (Mailbox * mbox , Heap * heap )
317+ {
318+ MailboxMessage * removed = mailbox_take_message (mbox );
319+ if (LIKELY (removed != NULL )) {
320+ mailbox_message_dispose (removed , heap );
321+ }
322+ }
323+
317324/**
318325 * @brief Output mailbox to stderr for crashdump reporting.
319326 *
0 commit comments