strdupa(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

strdupa(3c)

strdup(3C)               Standard C Library Functions               strdup(3C)

NAME
       strdup, strndup, strdupa, strndupa - string duplication

SYNOPSIS
       #include <string.h>

       char *strdup(const char *s);


       char *strndup(const char *s, size_t size);


       char *strdupa(const char *s);


       char *strndupa(const char *s, size_t size);

DESCRIPTION
       These  functions return a pointer to a newly allocated string (array of
       characters) which is a duplicate of the  string  s.  Depending  on  the
       function, the provided strings may be either terminated by a null char‐
       acter  or  bounded  by a maximum length of n bytes. The newly allocated
       strings will always be null-terminated.


       All character counts are measured in individual bytes, even if a string
       with multibyte characters is used, which may  result  in  copying  only
       part of a multibyte character if the full character does not fit within
       the byte count specified. They do not check for null pointers, and pro‐
       grams  may crash if passing null or otherwise invalid pointers to these
       functions.


       The strdup() function returns a pointer to a new string that is  a  du‐
       plicate  of  the  null-terminated  string pointed to by s. The returned
       pointer can be passed to free(). The space for the new  string  is  ob‐
       tained  using  malloc(3C).  If the new string cannot be created, a null
       pointer is returned and errno may be set to ENOMEM to indicate that the
       storage space available is insufficient.


       The strndup() function is similar to strdup(), except that it copies at
       most size bytes. If the length of s is  larger  than  size,  only  size
       bytes  are  copied  and  a  terminating  null byte is added. If size is
       larger than the length of s, all bytes in s are copied,  including  the
       terminating null character.


       The  strdupa()  and  strndupa()  functions  are similar to strdup() and
       strndup(), respectively, but use alloca(3C) to allocate the buffer.

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:

       tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE  TYPEAT‐
       TRIBUTE  VALUE  _  Interface  StabilityCommitted  _ MT-LevelSee below _
       StandardSee below


   MT-Level
       The strdup() and strndup() functions are MT-Safe.


       The strdupa() and strndupa() functions are Async-Signal-Safe.

   Standard
       See standards(7) for descriptions of the following standards:

       tab() box; cw(2.44i) |cw(3.06i) lw(2.44i) |lw(3.06i) INTERFACESAPPLICA‐
       BLE STANDARDS _ strdup()T{
         POSIX.1-2001 through 2008,
         SUSv3 through SUSv4,
         XPG6 through XPG7

       T} _ strndup()T{
         POSIX.1-2008,
         SUSv4,
         XPG7

       T} _ strdupa(), strndupa()None


SEE ALSO
       alloca(3C), malloc(3C), string(3C),  wcsdup(3C),  attributes(7),  stan‐
       dards(7)

HISTORY
       The strndup(), strdupa(), and strndupa() functions were added to Oracle
       Solaris in the Solaris 11.0.0 release.


       The  strdup() function has been included in all Sun and Oracle releases
       of Solaris.

Oracle Solaris 11.4               28 Feb 2022                       strdup(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3