1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-23 06:25:24 +00:00

Feature: Added helper function replace_string()

This commit is contained in:
Philipp Schafft 2018-09-14 07:53:28 +00:00
parent 6c491b3814
commit dabf9337a6
2 changed files with 23 additions and 0 deletions

View File

@ -1429,3 +1429,24 @@ int get_line(FILE *file, char *buf, size_t siz)
}
return 0;
}
int replace_string(char **dst, const char *src)
{
char *n;
if (!dst)
return -1;
if (src) {
n = strdup(src);
if (!n)
return -1;
} else {
n = NULL;
}
free(*dst);
*dst = n;
return 0;
}

View File

@ -128,4 +128,6 @@ struct tm *localtime_r(const time_t *timep, struct tm *result);
char *util_conv_string (const char *string, const char *in_charset, const char *out_charset);
int get_line(FILE *file, char *buf, size_t siz);
int replace_string(char **dst, const char *src);
#endif /* __UTIL_H__ */