src/cx/compare.h

changeset 985
68754c7de906
parent 890
54565fd74e74
--- a/src/cx/compare.h	Thu Nov 07 20:22:56 2024 +0100
+++ b/src/cx/compare.h	Thu Nov 07 22:46:58 2024 +0100
@@ -42,16 +42,15 @@
 extern "C" {
 #endif
 
-#ifndef CX_COMPARE_FUNC_DEFINED
-#define CX_COMPARE_FUNC_DEFINED
 /**
  * A comparator function comparing two collection elements.
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 typedef int(*cx_compare_func)(
         const void *left,
         const void *right
 );
-#endif // CX_COMPARE_FUNC_DEFINED
 
 /**
  * Compares two integers of type int.
@@ -61,6 +60,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_int(const void *i1, const void *i2);
 
 /**
@@ -71,6 +72,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_longint(const void *i1, const void *i2);
 
 /**
@@ -81,6 +84,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_longlong(const void *i1, const void *i2);
 
 /**
@@ -91,6 +96,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_int16(const void *i1, const void *i2);
 
 /**
@@ -101,6 +108,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_int32(const void *i1, const void *i2);
 
 /**
@@ -111,6 +120,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_int64(const void *i1, const void *i2);
 
 /**
@@ -121,6 +132,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_uint(const void *i1, const void *i2);
 
 /**
@@ -131,6 +144,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_ulongint(const void *i1, const void *i2);
 
 /**
@@ -141,6 +156,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_ulonglong(const void *i1, const void *i2);
 
 /**
@@ -151,6 +168,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_uint16(const void *i1, const void *i2);
 
 /**
@@ -161,6 +180,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_uint32(const void *i1, const void *i2);
 
 /**
@@ -171,6 +192,8 @@
  * @return -1, if *i1 is less than *i2, 0 if both are equal,
  * 1 if *i1 is greater than *i2
  */
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_uint64(const void *i1, const void *i2);
 
 /**
@@ -181,7 +204,8 @@
  * @return -1, if *f1 is less than *f2, 0 if both are equal,
  * 1 if *f1 is greater than *f2
  */
-
+cx_attr_nonnull
+cx_attr_nodiscard
 int cx_cmp_float(const void *f1, const void *f2);
 
 /**
@@ -192,10 +216,9 @@
  * @return -1, if *d1 is less than *d2, 0 if both are equal,
  * 1 if *d1 is greater than *d2
  */
-int cx_cmp_double(
-        const void *d1,
-        const void *d2
-);
+cx_attr_nonnull
+cx_attr_nodiscard
+int cx_cmp_double(const void *d1, const void *d2);
 
 /**
  * Compares the integer representation of two pointers.
@@ -205,10 +228,9 @@
  * @return -1 if *ptr1 is less than *ptr2, 0 if both are equal,
  * 1 if *ptr1 is greater than *ptr2
  */
-int cx_cmp_intptr(
-        const void *ptr1,
-        const void *ptr2
-);
+cx_attr_nonnull
+cx_attr_nodiscard
+int cx_cmp_intptr(const void *ptr1, const void *ptr2);
 
 /**
  * Compares the unsigned integer representation of two pointers.
@@ -218,10 +240,9 @@
  * @return -1 if *ptr1 is less than *ptr2, 0 if both are equal,
  * 1 if *ptr1 is greater than *ptr2
  */
-int cx_cmp_uintptr(
-        const void *ptr1,
-        const void *ptr2
-);
+cx_attr_nonnull
+cx_attr_nodiscard
+int cx_cmp_uintptr(const void *ptr1, const void *ptr2);
 
 /**
  * Compares the pointers specified in the arguments without de-referencing.
@@ -231,10 +252,9 @@
  * @return -1 if ptr1 is less than ptr2, 0 if both are equal,
  * 1 if ptr1 is greater than ptr2
  */
-int cx_cmp_ptr(
-        const void *ptr1,
-        const void *ptr2
-);
+cx_attr_nonnull
+cx_attr_nodiscard
+int cx_cmp_ptr(const void *ptr1, const void *ptr2);
 
 #ifdef __cplusplus
 } // extern "C"

mercurial