mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
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:
parent
04b46803cd
commit
43bf134aa1
1 changed files with 4 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue