BRK - change memory allocation.

(Slightly different from the UNIX version)

Usage:

int brk();
status = brk(newaddr);

Where:

char *newaddr;
is the new address of the "break", i.e. the lowest location in memory NOT used by the program (the top of the program).
int status;
is zero if "brk" is successful and -1 otherwise.

Description:

This function can increase the amount of memory available to the program. The argument "newaddr" points to an address that the program wants to be the new top of the program. This is automatically rounded up to the next multiple of 1024 words. If the program attempts to access addresses greater than or equal to "newaddr", the program will be given a memory fault.

Program set-up sets the starting "break" at the highest location defined by the program and data storage areas. Therefore, only programs that grow their data area will need to use "brk".

Notes:

"brk" and "sbrk" are only supplied for compatibility with UNIX. They serve no good purpose on GCOS-8 and may conflict with calls to "malloc" and other functions.

See Also:

expl c lib sbrk

Copyright © 1996, Thinkage Ltd.