nspawn-oci: add helper function for free_and_strdup with oom check

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-03-21 10:54:24 +01:00
parent 19130626a0
commit f1531db5af
2 changed files with 7 additions and 10 deletions

View File

@@ -180,6 +180,11 @@ char *strrep(const char *s, unsigned n);
int split_pair(const char *s, const char *sep, char **l, char **r);
int free_and_strdup(char **p, const char *s);
static inline int free_and_strdup_warn(char **p, const char *s) {
if (free_and_strdup(p, s) < 0)
return log_oom();
return 0;
}
int free_and_strndup(char **p, const char *s, size_t l);
char *string_erase(char *x);