Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdlib.h>
    void *sbrk( int increment );

Description:
    The sbrk sets the "break" value for the program by adding the value of
    increment to the current break value.  This increment may be positive or
    negative.

    The "break" value is the address of the first byte of unallocated
    memory.  When a program starts execution, the break value is placed
    following the code and constant data for the program.  As memory is
    allocated, this pointer will advance when there is no freed block large
    enough to satisfy an allocation request.

    A new process started with one of the  spawn...  or  exec...  functions
    is loaded following the break value.  Consequently, decreasing the break
    value leaves more space available to the new process.  Similarly, for a
    resident program (a program which remains in memory while another
    program executes), increasing the break value will leave more space
    available to be allocated by the resident program after other programs
    are loaded.

Returns:
    The function returns the old break value when the break value has been
    reset; otherwise, -1 is returned.  When an error has occurred,  errno
    contains a value indicating the type of error that has been detected.

See Also:
    calloc Functions Functions, _expand Functions Functions, free Functions Functions, halloc, hfree,
    malloc Functions Functions, _msize Functions Functions, realloc Functions Functions

Example:
    #include <stdio.h>
    #include <stdlib.h>

    void main()
     {
        void *brk;

        brk = sbrk( 0x0000 );
        printf( "Old break value %p\n", brk );
        brk = sbrk( -0x0100 );
        printf( "Old break value %p\n", brk );
        brk = sbrk( 0x0000 );
        printf( "New break value %p\n", brk );
     }

Classification:
    WATCOM

Systems:
    DOS, Win, QNX, OS/2 1.x, OS/2 1.x(MT), OS/2 2.x, NT

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson