1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-05 06:52:22 +03:00

sd-path,strv: add simple helper to wrap oom handling around strv_split_nulstr()

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-03-24 11:28:25 +01:00
parent b35ed5530b
commit a7addf32a5
2 changed files with 13 additions and 8 deletions

View File

@ -87,6 +87,16 @@ char **strv_parse_nulstr(const char *s, size_t l);
char **strv_split_nulstr(const char *s);
int strv_make_nulstr(char * const *l, char **p, size_t *n);
static inline int strv_from_nulstr(char ***a, const char *nulstr) {
char **t;
t = strv_split_nulstr(nulstr);
if (!t)
return -ENOMEM;
*a = t;
return 0;
}
bool strv_overlap(char * const *a, char * const *b) _pure_;
#define STRV_FOREACH(s, l) \

View File

@ -536,16 +536,11 @@ static int get_search(uint64_t type, char ***list) {
"/etc",
NULL);
case SD_PATH_SEARCH_BINARIES_DEFAULT: {
char **t;
case SD_PATH_SEARCH_BINARIES_DEFAULT:
return strv_from_nulstr(list, DEFAULT_PATH_NULSTR);
t = strv_split_nulstr(DEFAULT_PATH_NULSTR);
if (!t)
return -ENOMEM;
*list = t;
return 0;
}}
}
return -EOPNOTSUPP;
}