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,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 */ /* Checks a whitespace-separated list of words in haystack for needle */
bool pa_str_in_list_spaces(const char *haystack, const char *needle) { bool pa_str_in_list_spaces(const char *haystack, const char *needle) {
char *s; const char *s;
int n;
const char *state = NULL; const char *state = NULL;
if (!haystack || !needle) if (!haystack || !needle)
return false; return false;
while ((s = pa_split_spaces(haystack, &state))) { while ((s = pa_split_spaces_in_place(haystack, &n, &state))) {
if (pa_streq(needle, s)) { if (pa_strneq(needle, s, n))
pa_xfree(s);
return true; return true;
}
pa_xfree(s);
} }
return false; return false;