xref: /titanic_44/usr/src/man/man9f/freeb.9f (revision ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2ab)
te
Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
Copyright 1989 AT&T
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
FREEB 9F "Jan 16, 2006"
NAME
freeb - free a message block
SYNOPSIS

#include <sys/stream.h>



void freeb(mblk_t *bp);
PARAMETERS
bp

Pointer to the message block to be deallocated. mblk_t is an instance of the msgb(9S) structure.

INTERFACE LEVEL

Architecture independent level 1 (DDI/DKI).

DESCRIPTION

The freeb() function deallocates a message block. If the reference count of the db_ref member of the datab(9S) structure is greater than 1, freeb() decrements the count. If db_ref equals 1, it deallocates the message block and the corresponding data block and buffer.

If the data buffer to be freed was allocated with the esballoc(9F), the buffer may be a non-STREAMS resource. In that case, the driver must be notified that the attached data buffer needs to be freed, and run its own freeing routine. To make this process independent of the driver used in the stream, freeb() finds the free_rtn(9S) structure associated with the buffer. The free_rtn structure contains a pointer to the driver-dependent routine, which releases the buffer. Once this is accomplished, freeb() releases the STREAMS resources associated with the buffer.

CONTEXT

The freeb() function can be called from user, interrupt, or kernel context.

EXAMPLES

Example 1 Using freeb()

See copyb(9F) for an example of using freeb().

SEE ALSO

allocb(9F), copyb(9F), dupb(9F), esballoc(9F), free_rtn(9S)

Writing Device Drivers

STREAMS Programming Guide