pl_strdup.rst (868B)
1 PL_strdup 2 ========= 3 4 Returns a pointer to a new memory node in the NSPR heap containing a 5 copy of a specified string. 6 7 8 Syntax 9 ~~~~~~ 10 11 .. code:: 12 13 #include <plstr.h> 14 15 char *PL_strdup(const char *s); 16 17 18 Parameter 19 ~~~~~~~~~ 20 21 The function has a single parameter: 22 23 ``s`` 24 The string to copy, may be ``NULL``. 25 26 27 Returns 28 ~~~~~~~ 29 30 The function returns one of these values: 31 32 - If successful, a pointer to a copy of the specified string. 33 - If the memory allocation fails, ``NULL``. 34 35 36 Description 37 ~~~~~~~~~~~ 38 39 To accommodate the terminator, the size of the allocated memory is one 40 greater than the length of the string being copied. A ``NULL`` argument, 41 like a zero-length argument, results in a pointer to a one-byte block of 42 memory containing the null value. 43 44 Notes 45 ~~~~~ 46 47 The memory allocated by :ref:`PL_strdup` should be freed with 48 `PL_strfree </en/PL_strfree>`__.