.TH salloc() "" "" "Internal Kernel Routine"
.PC "Allocate a memory segment"
.B "#include <sys/seg.h>"
\fBSEG * salloc(\fIlen\^\fB, \fIflag\^\fB)\fR
\fBfsize_t \fIlen\^\fB; int \fIflags\^\fB;\fR
.PP
.B salloc()
allocates a segment of memory that is \fIlen\fR bytes long.
The segment reference count is set to one.
If more than one reference is made to the segment
(where each reference calls
.B sfree()
when done), the device driver increments the fields
.B s_urefc
and
.B s_refc
in the
.B SEG
structure.
.PP
.I flags
can be bitwise OR'd to contain any combination of the following values:
.IP \fBSFDOWN\fR 1.0i
The segment grows downward (e.g., stack segment for a process).
.IP \fBSFNCLR\fR
Do
.I not
clear memory in the allocated segment (usually to save time).
.IP \fBSFTEXT\fR
The segment may not be written to from user mode
.PP
If allocation succeeds,
.B salloc()
returns a pointer to a
.B SEG
structure that describes the requested segment.
The
.B SEG
structure has been taken from the
.B kalloc()
pool; memory for the segment itself is from the
.B sysmem
pool.
If allocation fails (i.e., not enough memory is available),
.B salloc()
returns NULL.
.SH "See Also"
.B
internal kernel routines
.R
