mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-16 08:56:40 -05:00
core-util: implement pa_split_spaces_strv()
This commit is contained in:
parent
c5dbf754b5
commit
7fa05bea7e
2 changed files with 26 additions and 0 deletions
|
|
@ -2744,3 +2744,27 @@ void pa_xfreev(void**a) {
|
||||||
|
|
||||||
pa_xfree(a);
|
pa_xfree(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char **pa_split_spaces_strv(const char *s) {
|
||||||
|
char **t, *e;
|
||||||
|
unsigned i = 0, n = 8;
|
||||||
|
const char *state = NULL;
|
||||||
|
|
||||||
|
t = pa_xnew(char*, n);
|
||||||
|
while ((e = pa_split_spaces(s, &state))) {
|
||||||
|
t[i++] = e;
|
||||||
|
|
||||||
|
if (i >= n) {
|
||||||
|
n *= 2;
|
||||||
|
t = pa_xrenew(char*, t, n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i <= 0) {
|
||||||
|
pa_xfree(t);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
t[i] = NULL;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -235,4 +235,6 @@ static inline void pa_xstrfreev(char **a) {
|
||||||
pa_xfreev((void**) a);
|
pa_xfreev((void**) a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char **pa_split_spaces_strv(const char *s);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue