mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
Add function to find a needle in a string array
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com> Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
This commit is contained in:
parent
ed1f031850
commit
069219577b
@ -1723,6 +1723,7 @@ virStorageFileResize;
|
||||
|
||||
|
||||
# util/virstring.h
|
||||
virStringArrayHasString;
|
||||
virStringFreeList;
|
||||
virStringJoin;
|
||||
virStringSplit;
|
||||
|
@ -166,3 +166,17 @@ void virStringFreeList(char **strings)
|
||||
}
|
||||
VIR_FREE(strings);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virStringArrayHasString(char **strings, const char *needle)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
while (strings[i]) {
|
||||
if (STREQ(strings[i++], needle))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -35,4 +35,6 @@ char *virStringJoin(const char **strings,
|
||||
|
||||
void virStringFreeList(char **strings);
|
||||
|
||||
bool virStringArrayHasString(char **strings, const char *needle);
|
||||
|
||||
#endif /* __VIR_STRING_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user