From 43bf134aa16303d04acbf37fb1e69c58f4905943 Mon Sep 17 00:00:00 2001 From: Hajime Fujita Date: Sun, 6 Nov 2016 12:53:57 -0600 Subject: [PATCH] core-util: do in-place search in pa_str_in_list_spaces Reviewed-by: Anton Lundin --- src/pulsecore/core-util.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 9d571b88d..cd1c96d40 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -3022,19 +3022,16 @@ bool pa_str_in_list(const char *haystack, const char *delimiters, const char *ne /* Checks a whitespace-separated list of words in haystack for needle */ bool pa_str_in_list_spaces(const char *haystack, const char *needle) { - char *s; + const char *s; + int n; const char *state = NULL; if (!haystack || !needle) return false; - while ((s = pa_split_spaces(haystack, &state))) { - if (pa_streq(needle, s)) { - pa_xfree(s); + while ((s = pa_split_spaces_in_place(haystack, &n, &state))) { + if (pa_strneq(needle, s, n)) return true; - } - - pa_xfree(s); } return false;