Duplicates a string.
If str is `NULL` it returns `NULL`.
str
the string to duplicate
a newly-allocated copy of str