src/ucx/compare.c

changeset 490
d218607f5a7e
parent 415
d938228c382e
--- a/src/ucx/compare.c	Sat Mar 25 17:18:51 2023 +0100
+++ b/src/ucx/compare.c	Fri May 05 18:02:11 2023 +0200
@@ -28,12 +28,11 @@
 
 #include "cx/compare.h"
 
-#include <stdint.h>
 #include <math.h>
 
 int cx_cmp_int(void const *i1, void const *i2) {
-    int a = *((const int*) i1);
-    int b = *((const int*) i2);
+    int a = *((const int *) i1);
+    int b = *((const int *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -42,8 +41,8 @@
 }
 
 int cx_cmp_longint(void const *i1, void const *i2) {
-    long int a = *((const long int*) i1);
-    long int b = *((const long int*) i2);
+    long int a = *((const long int *) i1);
+    long int b = *((const long int *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -52,8 +51,8 @@
 }
 
 int cx_cmp_longlong(void const *i1, void const *i2) {
-    long long a = *((const long long*) i1);
-    long long b = *((const long long*) i2);
+    long long a = *((const long long *) i1);
+    long long b = *((const long long *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -62,8 +61,8 @@
 }
 
 int cx_cmp_int16(void const *i1, void const *i2) {
-    int16_t a = *((const int16_t*) i1);
-    int16_t b = *((const int16_t*) i2);
+    int16_t a = *((const int16_t *) i1);
+    int16_t b = *((const int16_t *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -72,8 +71,8 @@
 }
 
 int cx_cmp_int32(void const *i1, void const *i2) {
-    int32_t a = *((const int32_t*) i1);
-    int32_t b = *((const int32_t*) i2);
+    int32_t a = *((const int32_t *) i1);
+    int32_t b = *((const int32_t *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -82,8 +81,8 @@
 }
 
 int cx_cmp_int64(void const *i1, void const *i2) {
-    int64_t a = *((const int64_t*) i1);
-    int64_t b = *((const int64_t*) i2);
+    int64_t a = *((const int64_t *) i1);
+    int64_t b = *((const int64_t *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -92,8 +91,8 @@
 }
 
 int cx_cmp_uint(void const *i1, void const *i2) {
-    unsigned int a = *((const unsigned int*) i1);
-    unsigned int b = *((const unsigned int*) i2);
+    unsigned int a = *((const unsigned int *) i1);
+    unsigned int b = *((const unsigned int *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -102,8 +101,8 @@
 }
 
 int cx_cmp_ulongint(void const *i1, void const *i2) {
-    unsigned long int a = *((const unsigned long int*) i1);
-    unsigned long int b = *((const unsigned long int*) i2);
+    unsigned long int a = *((const unsigned long int *) i1);
+    unsigned long int b = *((const unsigned long int *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -112,8 +111,8 @@
 }
 
 int cx_cmp_ulonglong(void const *i1, void const *i2) {
-    unsigned long long a = *((const unsigned long long*) i1);
-    unsigned long long b = *((const unsigned long long*) i2);
+    unsigned long long a = *((const unsigned long long *) i1);
+    unsigned long long b = *((const unsigned long long *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -122,8 +121,8 @@
 }
 
 int cx_cmp_uint16(void const *i1, void const *i2) {
-    uint16_t a = *((const uint16_t*) i1);
-    uint16_t b = *((const uint16_t*) i2);
+    uint16_t a = *((const uint16_t *) i1);
+    uint16_t b = *((const uint16_t *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -132,8 +131,8 @@
 }
 
 int cx_cmp_uint32(void const *i1, void const *i2) {
-    uint32_t a = *((const uint32_t*) i1);
-    uint32_t b = *((const uint32_t*) i2);
+    uint32_t a = *((const uint32_t *) i1);
+    uint32_t b = *((const uint32_t *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -142,8 +141,8 @@
 }
 
 int cx_cmp_uint64(void const *i1, void const *i2) {
-    uint64_t a = *((const uint64_t*) i1);
-    uint64_t b = *((const uint64_t*) i2);
+    uint64_t a = *((const uint64_t *) i1);
+    uint64_t b = *((const uint64_t *) i2);
     if (a == b) {
         return 0;
     } else {
@@ -152,8 +151,8 @@
 }
 
 int cx_cmp_float(void const *f1, void const *f2) {
-    float a = *((const float*) f1);
-    float b = *((const float*) f2);
+    float a = *((const float *) f1);
+    float b = *((const float *) f2);
     if (fabsf(a - b) < 1e-6f) {
         return 0;
     } else {
@@ -161,9 +160,12 @@
     }
 }
 
-int cx_cmp_double(void const *d1, void const *d2) {
-    double a = *((const double*) d1);
-    double b = *((const double*) d2);
+int cx_cmp_double(
+        void const *d1,
+        void const *d2
+) {
+    double a = *((const double *) d1);
+    double b = *((const double *) d2);
     if (fabs(a - b) < 1e-14) {
         return 0;
     } else {
@@ -171,12 +173,29 @@
     }
 }
 
-int cx_cmp_ptr(void const *ptr1, void const *ptr2) {
-    const intptr_t p1 = (const intptr_t) ptr1;
-    const intptr_t p2 = (const intptr_t) ptr2;
+int cx_cmp_intptr(
+        void const *ptr1,
+        void const *ptr2
+) {
+    intptr_t p1 = *(const intptr_t *) ptr1;
+    intptr_t p2 = *(const intptr_t *) ptr2;
     if (p1 == p2) {
         return 0;
     } else {
-        return p1  < p2 ? -1 : 1;
+        return p1 < p2 ? -1 : 1;
     }
 }
+
+int cx_cmp_uintptr(
+        void const *ptr1,
+        void const *ptr2
+) {
+    uintptr_t p1 = *(const uintptr_t *) ptr1;
+    uintptr_t p2 = *(const uintptr_t *) ptr2;
+    if (p1 == p2) {
+        return 0;
+    } else {
+        return p1 < p2 ? -1 : 1;
+    }
+}
+

mercurial