Memory Management
The sys_brk() system cal is provided by the kernel, to allocate memory without the need of moving it later. This call allocates memory right behind application image in memory. This system function al ows you to set the highest available address in the data section.
This system call takes one parameter, which is the highest memory address need to be set. This value is stored in the EBX register.
In case of any error, sys_brk() returns -1 or returns the negative error code itself. The following example demonstrates dynamic memory allocation.
Example:
The following program allocates 16kb of memory using the sys_brk() system call: