ucx/comparator.c

Wed, 27 Feb 2013 10:09:23 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 27 Feb 2013 10:09:23 +0100
changeset 89
47f7fdbddb62
child 91
91595a45fad6
permissions
-rw-r--r--

comparator module

     1 #include "comparator.h"
     3 int ucx_strcmp(void *s1, void *s2, void *data) {
     4     return strcmp((char*)s1, (char*)s2);
     5 }
     7 int ucx_strncmp(void *s1, void *s2, void *n) {
     8     return strncmp((char*)s1, (char*)s2, *((size_t*) n));
     9 }
    11 int ucx_intcmp(void *i1, void *i2, void *data) {
    12    int a = *((int*) i1);
    13    int b = *((int*) i2);
    14    if (a == b) {
    15        return 0;
    16    } else {
    17        return a < b ? -1 : 1;
    18    }
    19 }
    21 int ucx_ptrcmp(void *ptr1, void *ptr2, void *data) {
    22     if (ptr1 == ptr2) {
    23         return 0;
    24     } else {
    25         return ptr1 < ptr2 ? -1 : 1;
    26     }
    27 }

mercurial