sbrk
raw OCR
Changes data segment space allocation.
Defined in header <alloc.h>
Syntax
#include <alloc.h>
void *sbrk(int incr);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
sbrk adds incr bytes to the break value and changes the allocated space accordingly, incr can be negative, in which case the amount of allocated space is decreased.
sbrk will fail without making any change in the allocated space if such a change would result in more space being allocated than is allowable.
Return value
Upon successful completion, sbrk returns the old break value. On failure, sbrk returns a value of -1, and the global variable errno is set to
| ENOMEM | Not enough core |
See also
Example
#include <stdio.h>
#include <all(ic.h>
int main (void)
{
printf ("Changing allocation with sbrk;()\n");
printf ("Before sbrk() call: %lu bytes free\n", (unsigned long) coreleft());
sbrk(1000);
printf ("After sbrk() call: %lu bytes free\n", (unsigned long) coreleft());
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/alloc.h/sbrk/
· short form /3.1/sbrk/