Function SBRK

Syntax

sbrk increment => address, error

Arguments and values

increment -- An integer.

address -- A non-negative integer.

error -- A fixnum.

Description

The function sbrk changes the location of the program break, which defines the end of the process's data segment (i.e., the program break is the first location after the end of the uninitialized data segment). Increasing the program break has the effect of allocating memory to the process; decreasing the break deallocates memory.

The function sbrk increments the program's data space by increment bytes. Calling sbrk with an increment of 0 can be used to find the current location of the program break.

On success, sbrk returns the previous program break (a non-negative integer) as the first return value. If the break was increased, then this value is the address of the start of the newly allocated memory. On error, +enomem+ is returned as the second return value.

Errors

+enomem+ Either increment is invalid, or there is not enough memory to set the break to the desired value.