Commit dabf9337 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Feature: Added helper function replace_string()

parent 6c491b38
......@@ -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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment