rmvb(D3DK) —
.IX \f4rmvb\fP(D3DK)
NAME
rmvb − remove a message block from a message
SYNOPSIS
#include <sys/stream.h>
mblk_t ∗rmvb(mblk_t ∗mp, mblk_t ∗bp);
ARGUMENTS
mpMessage from which a message block is to be removed.
bpMessage block to be removed.
DESCRIPTION
rmvb removes a message block (bp) from a message (mp), and returns a pointer to the altered message. The message block is not freed, merely removed from the message. It is the caller’s responsibility to free the message block.
RETURN VALUE
If successful, a pointer to the message (minus the removed block) is returned. If bp was the only block in the message before rmvb was called, NULL is returned. If the designated message block (bp) was not in the message, −1 is returned.
LEVEL
Base or Interrupt.
NOTES
Does not sleep.
Driver-defined basic locks, read/write locks, and sleep locks may be held across calls to this function.
EXAMPLE
This routine removes all zero-length M_DATA message blocks from the given message. For each message block in the message, we save the next message block (line 9). If the current message block is of type M_DATA and has no data in its buffer (lines 10-11), then we remove the message block from the message (line 12) and free it (line 13). In either case, we continue with the next message block (line 15), until we have checked every message block in the message.
1 void
2 xxclean(mp)
3mblk_t ∗mp;
4 {
5mblk_t ∗tmp;
6mblk_t ∗nmp;
7tmp = mp;
8while (tmp) {
9nmp = tmp->b_next;
10if ((tmp->b_datap->db_type == M_DATA) &&
11 (tmp->b_rptr == tmp->b_wptr)) {
12mp = rmvb(mp, tmp);
13freeb(tmp);
14}
15tmp = nmp;
16}
17 }
.IX \f4freeb\fP(D3DK), example
.IX \f4rmvb\fP(D3DK), example
DDI/DKI — STREAMS