core-util: do in-place search in pa_str_in_list_spaces

Reviewed-by: Anton Lundin <glance@acc.umu.se>
This commit is contained in:
Hajime Fujita 2016-11-06 12:53:57 -06:00 committed by Tanu Kaskinen
parent 04b46803cd
commit 43bf134aa1

View file

@ -3022,21 +3022,18 @@ 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;
}