STREAMS-UX Programmer's Guide (February 2007)
STREAMS Utilities Supported by HP-UX
Appendix B
171
NAME
esballoc () – Allocate a message block using a caller specified buffer.
SYNOPSIS
#include <sys/stream.h>
mblk_t *esballoc(uchar_t *base, int size, int pri, frtn_t *fr_rtnp);
PARAMETERS
base
Pointer to caller data buffer.
size
Size of the data block.
pri
Priority of data block. It is no longer used. It is provided only the portability.
fr_rtnp
Pointer to free_rtn structure.
DESCRIPTION
esballoc() creates a message block, and attaches a caller-supplied data buffer to the data block and copies
the contents of the fr_rtn structure into the message block. esballoc() sets db_base, b_rptr, and b_wptr
fields to base (data buffer size) and db_lim to base+size. When freeb() is called to free the message, on the
last reference to the message, the caller’s free routine, specified by the free_func field in fr_rtnp structure
is called with one argument, specified by the free_arg field, to free the data buffer.
The free routine passed to esballoc() can call STREAMS/UX utilities similar to the ones called by put or
service procedure. Also, a free routine can safely access the same data structures as the put or service
procedure of the calling module or driver. However, HP-UX does not block interrupts from all STREAMS/UX
devices while the free routine runs.
RETURN VALUES
The success of esballoc() depends on the success of allocb() and that base, size, and fr_rtn are not
NULL, in which case esballoc() returns a pointer to a message block. If an error occurs, esballoc()
returns NULL.
CONSTRAINTS
esballoc() can be called from thread or interrupt context. Only spinlocks of STREAMS/UX user lock order
can be held across this call.