Determines the lowest virtual address that is not used with the program. Format #include <stdlib.h> void *brk (unsigned long int addr);
1 – Argument
addr The lowest address, which the function rounds up to the next multiple of the page size. This rounded address is called the break address.
2 – Description
An address that is greater than or equal to the break address and less than the stack pointer is considered to be outside the program's address space. Attempts to reference it will cause access violations. When a program is executed, the break address is set to the highest location defined by the program and data storage areas. Consequently, brk is needed only by programs that have growing data areas.
3 – Return Values
n The new break address. (void *)(-1) Indicates that the program is requesting too much memory. errno and vaxc$errno are updated.
4 – Restriction
Unlike other C library implementations, the Compaq C RTL memory allocation functions (such as malloc) do not rely on brk or sbrk to manage the program heap space. Consequently, on OpenVMS systems, calling brk or sbrk can interfere with memory allocation routines. The brk and sbrk functions are provided only for compatibility purposes.