Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

freeb(9f) [centos man page]

freeb(9F)						   Kernel Functions for Drivers 						 freeb(9F)

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
freeb() 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
freeb() can be called from user or interrupt 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 SunOS 5.10 13 Nov 2000 freeb(9F)

Check Out this Related Man Page

esballoc(9F)						   Kernel Functions for Drivers 					      esballoc(9F)

esballoc - allocate a message block using a caller-supplied buffer SYNOPSIS
#include <sys/stream.h> mblk_t *esballoc(uchar *base, size_t size, uint_t pri, frtn_t *fr_rtnp); INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI). PARAMETERS
base Address of user supplied data buffer. size Number of bytes in data buffer. pri Priority of allocation request (to be used by allocb(9F) function, called by esballoc()). fr_rtnp Free routine data structure. DESCRIPTION
esballoc() creates a STREAMS message and attaches a user-supplied data buffer in place of a STREAMS data buffer. It calls allocb(9F) to get a message and data block header only. The newly allocated message will have both the b_wptr and b_rptr set to the base of the buffer. As when using allocb(9F), the newly allocated message will have both b_wptr and b_rptr set to the base of the data buffer. The user-sup- plied data buffer, pointed to by base, is used as the data buffer for the message. When freeb(9F) is called to free the message, the driver's message freeing routine (referenced through the free_rtn structure) is called, with appropriate arguments, to free the data buffer. The free_rtn structure includes the following members: void (*free_func)(); /* user's freeing routine */ char *free_arg; /* arguments to free_func() */ Instead of requiring a specific number of arguments, the free_arg field is defined of type char *. This way, the driver can pass a pointer to a structure if more than one argument is needed. The method by which free_func is called is implementation-specific. The module writer must not assume that free_func will or will not be called directly from STREAMS utility routines like freeb(9F) which free a message block. free_func must not call another modules put procedure nor attempt to acquire a private module lock which may be held by another thread across a call to a STREAMS utility routine which could free a message block. Otherwise, the possibility for lock recursion and/or deadlock exists. free_func must not access any dynamically allocated data structure that might no longer exist when it runs. RETURN VALUES
On success, a pointer to the newly allocated message block is returned. On failure, NULL is returned. CONTEXT
esballoc() can be called from user or interrupt context. SEE ALSO
allocb(9F), freeb(9F), datab(9S), free_rtn(9S) Writing Device Drivers STREAMS Programming Guide WARNINGS
The free_func must be defined in kernel space, should be declared void and accept one argument. It has no user context and must not sleep. SunOS 5.10 23 Jun 1997 esballoc(9F)
Man Page

Featured Tech Videos