SBRK - change memory allocation.

(Slightly different from the UNIX version)

Usage:

char *sbrk();
newaddr = sbrk(increment);

Where:

int increment;
gives the number of bytes to add to the current value of the "break", i.e. the lowest location in memory NOT used by the program (the top of the program).
char *newaddr;
receives the new address of the "break".

Description:

This function adds "increment" bytes to the amount of memory currently allocated for your program. This is automatically rounded up to the next multiple of 1024 words. If the program attempts to access addresses beyond the end of allocated memory, it will be aborted with a memory fault.

If "sbrk" cannot grow your program, the program is aborted. If "increment" is negative, "sbrk" returns a NULL pointer.

Notes:

"brk" and "sbrk" are only included for compatibility with UNIX. Using these functions to grow your program may cause conflicts with "malloc" and other functions. The only really sensible use of "sbrk" is

sbrk(0)

which will return a pointer to the end of your program's allocated memory, thereby telling you how big your program is.

See Also:

expl c lib brk

Copyright © 1996, Thinkage Ltd.