Go to the first, previous, next, last section, table of contents.


sbrk

Syntax

#include <unistd.h>

void *sbrk(int delta)

Description

This function changes the "break" of the program by adding delta to it. This is the highest address that your program can access without causing a violation. Since the heap is the region under the break, you can expand the heap (where malloc gets memory from) by increasing the break.

This function is normally accessed only by malloc (see section malloc).

Return Value

The address of the first byte outside of the previous valid address range, or -1 if no more memory could be accessed. In other words, a pointer to the chunk of heap you just allocated, if you had passed a positive number.

Portability

not ANSI, not POSIX

Example

char *buf;
buf = sbrk(1000); /* allocate space */


Go to the first, previous, next, last section, table of contents.