adds ucx_sstrcmp() compare function to utils.h

Fri, 11 May 2018 18:13:54 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 11 May 2018 18:13:54 +0200
changeset 292
d9abf53b8397
parent 291
deb0035635eb
child 293
d994325445f1

adds ucx_sstrcmp() compare function to utils.h

src/ucx/utils.h file | annotate | diff | comparison | revisions
src/utils.c file | annotate | diff | comparison | revisions
--- a/src/ucx/utils.h	Fri May 11 17:40:16 2018 +0200
+++ b/src/ucx/utils.h	Fri May 11 18:13:54 2018 +0200
@@ -156,6 +156,15 @@
 int ucx_strncmp(const void *s1, const void *s2, void *n);
 
 /**
+ * Wraps the sstrcmp function.
+ * @param s1 sstr one
+ * @param s2 sstr two
+ * @param data ignored
+ * @return the result of sstrcmp(s1, s2)
+ */
+int ucx_sstrcmp(const void *s1, const void *s2, void *data);
+
+/**
  * Compares two integers of type int.
  * @param i1 pointer to integer one
  * @param i2 pointer to integer two
--- a/src/utils.c	Fri May 11 17:40:16 2018 +0200
+++ b/src/utils.c	Fri May 11 18:13:54 2018 +0200
@@ -96,6 +96,12 @@
     return strncmp((const char*)s1, (const char*)s2, *((size_t*) n));
 }
 
+int ucx_sstrcmp(const void *s1, const void *s2, void *data) {
+    sstr_t a = *(const sstr_t*) s1;
+    sstr_t b = *(const sstr_t*) s2;
+    return sstrcmp(a, b);
+}
+
 int ucx_intcmp(const void *i1, const void *i2, void *data) {
    int a = *((const int*) i1);
    int b = *((const int*) i2);

mercurial