Next: , Previous: Strings, Up: Strings   [Contents]


4.1 str_dup

duplicate a string

Synopsis

#include <suplib/str.h>

char *str_dup(const char *string);

Parameters

const char *string

the string to duplicate

Description

str_dup makes a duplicate copy of a string, allocating space and copying the original into the new space. If the passed pointer is NULL, it returns NULL.

Returns

Upon success, it returns a pointer to the duplicate string. The user is responsible for freeing this memory. Upon failure (i.e., out of memory) it returns NULL

Author

Diab Jerius