delorie.com/djgpp/doc/libc/libc_669.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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

ANSI/ISO C No
POSIX No

Example

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


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004