提交 06921957 编写于 作者: S Stefan Berger 提交者: Stefan Berger

Add function to find a needle in a string array

Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: NCorey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: NCorey Bryant <coreyb@linux.vnet.ibm.com>
上级 ed1f0318
......@@ -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__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册