.TH BRK 2.SH NAMEbrk, sbrk \- change memory allocation.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.PP.ta \w'\fLvoid* 'u.Bint brk(void *addr).PP.Bvoid* sbrk(ulong incr).SH DESCRIPTION.I Brksets the system's idea of the lowest bss location not used by the program(called the break)to.I addrrounded up to the next multiple of 8 bytes.Locations not less than.I addrand below the stack pointermay cause a memory violation if accessed..PPIn the alternate function.IR sbrk ,.I incrmore bytes are added to theprogram's data space and a pointer to thestart of the new area is returned.Rounding occurs as with.IR brk ..PPWhen a program begins execution via.I execthe break is set at thehighest location defined by the programand data storage areas.Ordinarily, therefore, only programs with growingdata areas need to use.IR brk .A call to.I sbrkwith a zero argument returns the lowest addressin the dynamic segment..SH SOURCE.B /sys/src/libc/9sys/sbrk.c.SH SEE ALSO.IR intro (2),.IR malloc (2),.IR segattach (2),.IR segbrk (2).SH DIAGNOSTICSThese functions set.IR errstr ..PPThe error return from.I sbrkis.BR (void*)-1 .
.TH BRK 2
.SH NAME
brk, sbrk \- change memory allocation
.SH SYNOPSIS
.B #include <u.h>
.br
.B #include <libc.h>
.PP
.ta \w'\fLvoid* 'u
.B
int brk(void *addr)
.PP
.B
void* sbrk(ulong incr)
.SH DESCRIPTION
.I Brk
sets the system's idea of the lowest bss location not used by the program
(called the break)
to
.I addr
rounded up to the next multiple of 8 bytes.
Locations not less than
.I addr
and below the stack pointer
may cause a memory violation if accessed.
.PP
In the alternate function
.IR sbrk ,
.I incr
more bytes are added to the
program's data space and a pointer to the
start of the new area is returned.
Rounding occurs as with
.IR brk .
.PP
When a program begins execution via
.I exec
the break is set at the
highest location defined by the program
and data storage areas.
Ordinarily, therefore, only programs with growing
data areas need to use
.IR brk .
A call to
.I sbrk
with a zero argument returns the lowest address
in the dynamic segment.
.SH SOURCE
.B /sys/src/libc/9sys/sbrk.c
.SH SEE ALSO
.IR intro (2),
.IR malloc (2),
.IR segattach (2),
.IR segbrk (2)
.SH DIAGNOSTICS
These functions set
.IR errstr .
.PP
The error return from
.I sbrk
is
.BR (void*)-1 .