Provided by: manpages-pl-dev_4.14.0-4_all bug

NAZWA

       brk, sbrk - zmiana wielkości segmentu danych

SKŁADNIA

       #include <unistd.h>

       int brk(void *addr);

       void *sbrk(intptr_t increment);

   Wymagane ustawienia makr biblioteki glibc (patrz feature_test_macros(7)):

       brk(), sbrk():
           Od glibc 2.19:
               _DEFAULT_SOURCE ||
                   (_XOPEN_SOURCE >= 500) &&
                   ! (_POSIX_C_SOURCE >= 200112L)
           glibc 2.12 do 2.19:
               _BSD_SOURCE || _SVID_SOURCE ||
                   (_XOPEN_SOURCE >= 500) &&
                   ! (_POSIX_C_SOURCE >= 200112L)
           Przed glibc 2.12:
               _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500

OPIS

       brk()   and sbrk()  change the location of the program break, which defines the end of the
       process's data segment (i.e., the program break is the first location after the end of the
       uninitialized  data  segment).   Increasing the program break has the effect of allocating
       memory to the process; decreasing the break deallocates memory.

       brk ustawia koniec segmentu danych na wartość podaną jako argument addr, o ile wartość  ta
       jest  sensowna,  system  posiada  dostateczną ilość pamięci oraz nie zostanie przekraczona
       maksymalna wielkość segmentu danych dla procesu (zobacz setrlimit(2)).

       sbrk() zwiększa przestrzeń danych programu o wartość increment bajtów. Wywołanie sbrk()  z
       increment  równym  0  może  służyć do znalezienia aktualnej lokalizacji punktu zakończenia
       programu.

WARTOŚĆ ZWRACANA

       Po pomyślnym zakończeniu brk() zwraca zero. Po błędzie zwracane jest -1, a errno ustawiane
       jest na ENOMEM.

       On success, sbrk()  returns the previous program break.  (If the break was increased, then
       this value is a  pointer  to  the  start  of  the  newly  allocated  memory).   On  error,
       (void *) -1 is returned, and errno is set to ENOMEM.

ZGODNE Z

       4.3BSD; SUSv1, marked LEGACY in SUSv2, removed in POSIX.1-2001.

UWAGI

       Avoid  using  brk()   and sbrk(): the malloc(3)  memory allocation package is the portable
       and comfortable way of allocating memory.

       Various systems use various types for the argument of sbrk().  Common  are  int,  ssize_t,
       ptrdiff_t, intptr_t.

   Różnice biblioteki C/jądra
       The  return value described above for brk()  is the behavior provided by the glibc wrapper
       function for the Linux brk()  system call.  (On most  other  implementations,  the  return
       value  from  brk()  is the same; this return value was also specified in SUSv2.)  However,
       the actual Linux system call returns the new program break on success.   On  failure,  the
       system  call  returns the current break.  The glibc wrapper function does some work (i.e.,
       checks whether the new break is less than addr)  to provide the 0  and  -1  return  values
       described above.

       On  Linux,  sbrk()  is implemented as a library function that uses the brk()  system call,
       and does some internal bookkeeping so that it can return the old break value.

ZOBACZ TAKŻE

       execve(2), getrlimit(2), end(3), malloc(3)

O STRONIE

       Angielska wersja tej strony  pochodzi  z  wydania  5.10  projektu  Linux  man-pages.  Opis
       projektu,  informacje  dotyczące  zgłaszania  błędów oraz najnowszą wersję oryginału można
       znaleźć pod adresem https://www.kernel.org/doc/man-pages/.

TŁUMACZENIE

       Autorami  polskiego  tłumaczenia  niniejszej  strony   podręcznika   są:   Przemek   Borys
       <pborys@dione.ids.pl>,  Andrzej  Krzysztofowicz <ankry@green.mf.pg.gda.pl> i Michał Kułach
       <michal.kulach@gmail.com>

       Niniejsze tłumaczenie jest wolną dokumentacją. Bliższe  informacje  o  warunkach  licencji
       można   uzyskać   zapoznając   się   z   GNU   General   Public   License   w   wersji   3
       ⟨https://www.gnu.org/licenses/gpl-3.0.html⟩  lub  nowszej.  Nie   przyjmuje   się   ŻADNEJ
       ODPOWIEDZIALNOŚCI.

       Błędy  w  tłumaczeniu  strony  podręcznika  prosimy  zgłaszać  na  adres listy dyskusyjnej
       ⟨manpages-pl-list@lists.sourceforge.net⟩.