Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
strdup(3) Guardian Native C Library Calls Reference Manual
NAME
strdup - Duplicates a string
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
SYNOPSIS
#include <string.h>
char *strdup(
const char s1);
PARAMETERS
s1 Points to the string to be duplicated.
DESCRIPTION
The strdup( ) function returns a pointer to a new string, which is a duplicate of the string pointed
to by s1. The returned pointer can be passed to the free() function. A null pointer is returned if
the new string cannot be created.
Use From the Guardian Environment
The strdup( ) function can be used by a Guardian process when the process has been compiled
using the #define _XOPEN_SOURCE_EXTENDED 1 feature-test macro or an equivalent com-
piler command option.
RETURN VALUES
Upon successful completion, a pointer to a string is returned. Otherwise, strdup() returns a null
pointer and sets errno to indicate the error.
ERRORS
If the following condition occurs, this function sets errno to the corresponding value.
[ENOMEM] There is not enough storage available in the system.
RELATED INFORMATION
Functions: free(3), malloc(3).
STANDARDS CONFORMANCE
The strdup( ) function is defined in the XPG4 Version 2 specification.
6−90 Hewlett-Packard Company 527192-018