[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 02/11] Add function to find a needle in a string array



Signed-off-by: Stefan Berger <stefanb linux vnet ibm com>

---
 src/libvirt_private.syms |    1 +
 src/util/virstring.c     |   16 ++++++++++++++++
 src/util/virstring.h     |    2 ++
 3 files changed, 19 insertions(+)

Index: libvirt/src/util/virstring.c
===================================================================
--- libvirt.orig/src/util/virstring.c
+++ libvirt/src/util/virstring.c
@@ -166,3 +166,19 @@ void virStringFreeList(char **strings)
     }
     VIR_FREE(strings);
 }
+
+
+bool
+virStringArrayHasString(char **strings, const char *needle)
+{
+    size_t i = 0;
+
+    while (true) {
+        if (!strings[i])
+            break;
+        if (STREQ(strings[i++], needle))
+            return true;
+    }
+
+    return false;
+}
Index: libvirt/src/util/virstring.h
===================================================================
--- libvirt.orig/src/util/virstring.h
+++ libvirt/src/util/virstring.h
@@ -35,4 +35,6 @@ char *virStringJoin(const char **strings
 
 void virStringFreeList(char **strings);
 
+bool virStringArrayHasString(char **strings, const char *needle);
+
 #endif /* __VIR_STRING_H__ */
Index: libvirt/src/libvirt_private.syms
===================================================================
--- libvirt.orig/src/libvirt_private.syms
+++ libvirt/src/libvirt_private.syms
@@ -1698,6 +1698,7 @@ virStorageFileResize;
 
 
 # util/virstring.h
+virStringArrayHasString;
 virStringFreeList;
 virStringJoin;
 virStringSplit;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]