*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->HP-UX 11i man pages -> brk (2)              
Title
Content
Arch
Section
 

Contents


 brk(2)                                                               brk(2)




 NAME    [Toc]    [Back]
      brk, sbrk - change data segment space allocation

 SYNOPSIS    [Toc]    [Back]
      #include <unistd.h>

      int brk(const void *endds);

      void *sbrk(int incr);

 DESCRIPTION    [Toc]    [Back]
      brk() and sbrk() are used to change dynamically the amount of space
      allocated for the calling process's data segment; see exec(2).  The
      change is made by resetting the process's break value and allocating
      the appropriate amount of space.  The break value is the address of
      the first location beyond the end of the data segment.  The amount of
      allocated space increases as the break value increases.  The newly
      allocated space is set to zero.

      brk() sets the break value to endds and changes the allocated space
      accordingly.

      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.

 ERRORS    [Toc]    [Back]
      brk() and sbrk() fail without making any change in the allocated space
      if one or more of the following are true:

      [ENOMEM]       Such a change would result in more space being
                     allocated than is allowed by a system-imposed maximum
                     (see ulimit(2)).

      [ENOMEM]       Such a change would cause a conflict between addresses
                     in the data segment and any attached shared memory
                     segment (see shmop(2)).

      [ENOMEM]       Such a change would be impossible as there is
                     insufficient swap space available.

      [EINVAL]       Such a change will result in crossing the boundary to
                     uninitialized data in the calling process's data
                     segment.

 WARNINGS    [Toc]    [Back]
      The pointer returned by sbrk() is not necessarily word-aligned.
      Loading or storing words through this pointer could cause word
      alignment problems.





 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003






 brk(2)                                                               brk(2)




      Be very careful when using either brk or sbrk in conjunction with
      calls to the malloc(3C) library routines.  There is only one program
      data segment from which all three of these routines allocate and
      deallocate program data memory.

 RETURN VALUE    [Toc]    [Back]
      Upon successful completion, brk() returns a value of 0. Otherwise, a
      value of -1 is returned and errno is set to indicate the error.

      Upon successful completion, sbrk() returns the old break value.
      Otherwise, SBRK_FAILED is returned and errno is set to indicate the
      error. The symbol SBRK_FAILED is defined in the header <unistd.h>.  No
      successful return from sbrk() will return the value SBRK_FAILED.

 AUTHOR    [Toc]    [Back]
      brk() and sbrk() were developed by AT&T and HP.

 SEE ALSO    [Toc]    [Back]
      exec(2), shmop(2), ulimit(2), end(3C), malloc(3C).

 STANDARDS CONFORMANCE    [Toc]    [Back]
      brk(): XPG2

      sbrk(): XPG2


 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003
[ Back ]
      
      
 Similar pages
Name OS Title
brk Tru64 Change space allocation
sbrk Tru64 Change space allocation
brk NetBSD change data segment size
sbrk FreeBSD change data segment size
sbrk OpenBSD change data segment size
brk OpenBSD change data segment size
sbrk NetBSD change data segment size
brk Linux change data segment size
brk FreeBSD change data segment size
munlock HP-UX unlock a segment of the process virtual address space
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service