[PATCH 1/2] util: Introduce virStrcmp into virstring.

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

 



Signed-off-by: yangdongsheng <yangds.fnst@xxxxxxxxxxxxxx>
---
 src/util/virstring.c |   14 ++++++++++++++
 src/util/virstring.h |    2 ++
 2 files changed, 16 insertions(+)

diff --git a/src/util/virstring.c b/src/util/virstring.c
index 1937f82..9dbc1b0 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -382,6 +382,20 @@ virStrncpy(char *dest, const char *src, size_t n, size_t destbytes)
 }
 
 /**
+ * virStrcmp
+ *
+ * return 0 if what a point is equal to what b point.
+ * else return -1.
+ */
+int
+virStrcmp(const char *a, const char *b)
+{
+    if (strcmp(a, b) != 0)
+        return -1;
+    return 0;
+}
+
+/**
  * virStrcpy
  *
  * A safe version of strcpy.  The last parameter is the number of bytes
diff --git a/src/util/virstring.h b/src/util/virstring.h
index 34ffae1..5448665 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -88,6 +88,8 @@ char *virStrcpy(char *dest, const char *src, size_t destbytes)
     ATTRIBUTE_RETURN_CHECK;
 # define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
 
+int virStrcmp(const char *a, const char *b);
+
 /* Don't call these directly - use the macros below */
 int virStrdup(char **dest, const char *src, bool report, int domcode,
               const char *filename, const char *funcname, size_t linenr)
-- 
1.7.10.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]