summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-06-17 03:13:32 +0200
committerLennart Poettering <lennart@poettering.net>2009-06-17 03:13:32 +0200
commit7fa05bea7e9980243cf58902b9d42e995d1a18bf (patch)
tree2050fbbf50eb579b223cc817262de1fff53c14ca /src/pulsecore
parentc5dbf754b578d70d5bf01494fedad74c1829ac38 (diff)
core-util: implement pa_split_spaces_strv()
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/core-util.c24
-rw-r--r--src/pulsecore/core-util.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 0b64edba..e39adb12 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2744,3 +2744,27 @@ void pa_xfreev(void**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;
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 5a12ad3f..d88b7cbb 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -235,4 +235,6 @@ static inline void pa_xstrfreev(char **a) {
pa_xfreev((void**) a);
}
+char **pa_split_spaces_strv(const char *s);
+
#endif