rmvb(D3)
rmvb - remove a message block from a message
As shipped in IRIX 6.5.30. Unchanged since IRIX 6.5.
NAME rmvb - remove a message block from a message SYNOPSIS #include <sys/stream.h> #include <sys/ddi.h> mblk_t *rmvb(mblk_t *mp, mblk_t *bp); Arguments mp Pointer to the message from which a message block is to be removed. bp Pointer to the message block to be removed. DESCRIPTION rmvb removes the message block specified by bp from the message specified mp and returns a pointer to the altered message. Return Values On success, 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. USAGE The message block is not freed, merely removed from the message. It is the caller's responsibility to free the message block. Level Base or Interrupt. Synchronization Constraints Does not sleep. Driver-defined basic locks, read/write locks, and sleep locks may be held across calls to this function. Examples 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) 3 mblk_t *mp; 4 { 5 mblk_t *tmp; 6 mblk_t *nmp; 7 tmp = mp; 8 while (tmp) { 9 nmp = tmp->b_next; 10 if ((tmp->b_datap->db_type == M_DATA) && 11 (tmp->b_rptr == tmp->b_wptr)) { 12 mp = rmvb(mp, tmp); 13 freeb(tmp); 14 } 15 tmp = nmp; 16 } 17 }