src/cx/compare.h

changeset 1634
006e076a8db7
parent 1632
f74e4fc496a2
equal deleted inserted replaced
1633:fe24b68758bf 1634:006e076a8db7
532 * @retval 1 if the left argument is greater than the right argument 532 * @retval 1 if the left argument is greater than the right argument
533 */ 533 */
534 cx_attr_nonnull cx_attr_nodiscard 534 cx_attr_nonnull cx_attr_nodiscard
535 CX_EXPORT int cx_cmp_ptr(const void *ptr1, const void *ptr2); 535 CX_EXPORT int cx_cmp_ptr(const void *ptr1, const void *ptr2);
536 536
537 /** 537 /** Wraps a compare function for cx_cmp_wrap. */
538 * A @c cx_compare_func2 compatible wrapper for @c memcmp().
539 *
540 * @param ptr1 pointer one
541 * @param ptr2 pointer two
542 * @param n (@c size_t*) a pointer to the length
543 * @return the result of @c memcmp()
544 */
545 cx_attr_nonnull cx_attr_nodiscard
546 CX_EXPORT int cx_ccmp_memcmp(const void *ptr1, const void *ptr2, void *n);
547
548 /** Wraps a compare function for cx_ccmp_wrap. */
549 typedef struct { 538 typedef struct {
550 /** The wrapped compare function */ 539 /** The wrapped compare function */
551 cx_compare_func cmp; 540 cx_compare_func cmp;
552 } cx_compare_func_wrapper; 541 } cx_compare_func_wrapper;
553 542
554 /** 543 /**
555 * A @c cx_compare_func2 wrapper for a @c cx_compare_func(). 544 * A @c cx_compare_func2 wrapper for a @c cx_compare_func().
556 * 545 *
557 * This is not strictly compatible with a @c cx_compare_func2 because
558 * ISO C does not define conversions between function and object pointers.
559 *
560 * But it works on all tested platforms to cast a pointer to this function to
561 * a @c cx_compare_func2.
562 *
563 * @param ptr1 pointer one 546 * @param ptr1 pointer one
564 * @param ptr2 pointer two 547 * @param ptr2 pointer two
565 * @param cmp_wrapper a pointer to a @c cx_compare_func_wrapper 548 * @param cmp_wrapper a pointer to a @c cx_compare_func_wrapper
566 * @return the result of the invoked compare function 549 * @return the result of the invoked compare function
567 * @see cx_compare_func_wrapper_s 550 * @see cx_compare_func_wrapper
568 */ 551 */
569 cx_attr_nonnull cx_attr_nodiscard 552 cx_attr_nonnull cx_attr_nodiscard
570 CX_EXPORT int cx_ccmp_wrap(const void *ptr1, const void *ptr2, void* cmp_wrapper); 553 CX_EXPORT int cx_cmp_wrap(const void *ptr1, const void *ptr2, void* cmp_wrapper);
571 554
572 #ifdef __cplusplus 555 #ifdef __cplusplus
573 } // extern "C" 556 } // extern "C"
574 #endif 557 #endif
575 558

mercurial