Changes data segment space allocation.
#include <unistd .h>
int brk ( EndDataSegment)
char *EndDataSegment;
void *sbrk ( Increment)
intptr_t Increment;
The brk and sbrk subroutines dynamically change the amount of space allocated for the data segment of the calling process. (For information about segments, see the exec subroutine. For information about the maximum amount of space that can be allocated, see the ulimit and getrlimit subroutines.)
The change is made by resetting the break value of the process, which determines the maximum space that can be allocated. The break value is the address of the first location beyond the current end of the data region. The amount of available space increases as the break value increases. The available space is initialized to a value of 0 at the time it is used. The break value can be automatically rounded up to a size appropriate for the memory management architecture.
The brk subroutine sets the break value to the value of the EndDataSegment parameter and changes the amount of available space accordingly.
The sbrk subroutine adds to the break value the number of bytes contained in the Increment parameter and changes the amount of available space accordingly. The Increment parameter can be a negative number, in which case the amount of available space is decreased.
EndDataSegment | Specifies the effective address of the maximum available data. |
Increment | Specifies any integer. |
Upon successful completion, the brk subroutine returns a value of 0, and the sbrk subroutine returns the old break value. If either subroutine is unsuccessful, a value of -1 is returned and the errno global variable is set to indicate the error.
The brk subroutine and
the sbrk subroutine are unsuccessful and the allocated space
remains unchanged if one or more of the following are true:
These subroutines are part of Base Operating System (BOS) Runtime.
The exec (exec: execl, execle, execlp, execv, execve, execvp, or exect Subroutine) subroutines, getrlimit (getrlimit, getrlimit64, setrlimit, setrlimit64, or vlimit Subroutine) subroutine, shmat subroutine, shmdt subroutine, ulimit subroutine.
The _end (_end, _etext, or _edata Identifier), _etext (_end, _etext, or _edata Identifier), or _edata (_end, _etext, or _edata Identifier) identifier.
Subroutine Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.