Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ (2) — Plan9 1st Edition

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

intro(2)

malloc(2)

BRK(2)

NAME

brk, sbrk − change memory allocation

SYNOPSIS

intbrk(void ∗addr)

void∗sbrk(ulong incr)

DESCRIPTION

­Brk sets the system’s idea of the lowest non-stack location not used by the program (called the break) to ­addr rounded up to the next multiple of 4 bytes.  Locations not less than ­addr and below the stack pointer may cause a memory violation if accessed. 

In the alternate function ­sbrk, ­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 brk.

When a program begins execution via ­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 brk. A call to ­sbrk with a zero argument returns the lowest address in the dynamic segment. 

SEE ALSO

intro(2), malloc(2)

DIAGNOSTICS

These functions set ­errstr. 

The error return from ­sbrk is (void ∗)-1. 

Plan 9  —  January 03, 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026