mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Feature: Added helper function replace_string()
This commit is contained in:
parent
6c491b3814
commit
dabf9337a6
21
src/util.c
21
src/util.c
@ -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;
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user