[misc] Helper function safe_strdup (NULL safe strdup)

This commit is contained in:
chme 2017-01-01 10:23:34 +01:00
parent 4bd42dda41
commit 263edaa8b3
2 changed files with 11 additions and 0 deletions

View File

@ -261,6 +261,15 @@ safe_hextou64(const char *str, uint64_t *val)
return 0;
}
char *
safe_strdup(const char *str)
{
if (str == NULL)
return NULL;
return strdup(str);
}
/* Key/value functions */
struct keyval *

View File

@ -41,6 +41,8 @@ safe_atou64(const char *str, uint64_t *val);
int
safe_hextou64(const char *str, uint64_t *val);
char *
safe_strdup(const char *str);
/* Key/value functions */
struct keyval *