.TH esballoc() "" "" "DDI/DKI Kernel Routine"
.PC "Allocate a message block using a driver-supplied buffer"
.B "#include <sys/stream.h>"
\fBmblk_t *esballoc(\fIbuffer\^\fB, \fIsize\^\fB, \fIpriority\^\fB, \fIfreefun\^\fB)\fR
\fBuchar_t *\fIbuffer\^\fB; int \fIsize\^\fB, \fIpriority\^\fB; frtn_t *\fIfreefun\^\fB;\fR
.PP
.B esballoc()
allocates a \*(ST message and the data-block header,
and attaches to them a data buffer that the driver supplies.
.PP
.I buffer
points to the base of the data buffer that the driver supplying, and which is
.I size
bytes long.
.PP
.I priority
gives the priority of the allocation request.
It must be one of
.BR BPRI_LO ,
.BR BPRI_MED ,
or
.BR BPRI_HI ,
for, respectively, low-, medium-, or high-priority messages.
.PP
.I freefun
points to the data structure that describes the routine to free
the driver-allocated message buffer.
When the kernel calls
.B freeb()
upon the last reference to this message,
it invokes the routine \fIfreefun\fB->free_func\fR.
For details, see the Lexicon entry for
.BR free_rtn .
.PP
If all goes well,
.B esballoc()
returns a pointer to the newly allocated message block; if not,
it returns NULL.
.SH "See Also"
.B
allocb(),
DDI/DKI kernel routines,
freeb(),
free_rtn,
msgb
.R
.SH Notes
.B esballoc()
has base or interrupt level.
It does not sleep.
.PP
A driver can hold a
driver-defined basic lock, read/write lock, or sleep lock
across a call to this function.
