Embedded Artistry Framework
Embedded Systems C++ Framework
Functions
strdup.c File Reference
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for strdup.c:

Functions

char * strdup (const char *str)
 Duplicate the passed in string str. More...
 

Function Documentation

◆ strdup()

char* strdup ( const char *  str)

Duplicate the passed in string str.

Returns a pointer to a new string which is a duplicate of the string str. Memory for the new string is obtained with malloc(3), and can be freed with free(3).

Parameters
stra pointer to a string to duplicate
Returns
a pointer to the duplicated string on success. NULL if insufficient memory was available, with errno set to indicate cause of error.

References malloc(), memcpy(), NULL, and strlen().

Referenced by strdup_test().

Here is the caller graph for this function: