[ccan] [PATCH 0/4] order_functions: Helpers for comparison callbacks

David Gibson david at gibson.dropbear.id.au
Mon Jun 1 20:21:04 AEST 2015


Standard library routines like qsort() and bsearch() take a
user-defined comparison callback in order to determine the order of
the elements they're handling.  The asort, asearch and avl ccan
modules use a similar pattern.

This patch series creates a new order_functions module with some
useful things for using this pattern.  First it provides some standard
datatypes for comparison functions.  Second it provides some sample
comparison functions for common cases.

This also converts the asort and avl modules to use order_functions.

David Gibson (4):
  order_functions: Module for comparison callbacks
  order_functions: Scalar comparison functions
  asort: Use order_functions module definitions
  avl: Use definitions from order_functions module

 ccan/asort/_info                           |   2 +-
 ccan/asort/asort.h                         |  12 +--
 ccan/avl/_info                             |   4 +-
 ccan/avl/avl.c                             |   2 +-
 ccan/avl/avl.h                             |   8 +-
 ccan/avl/test/run.c                        |  14 +--
 ccan/order_functions/LICENSE               |   1 +
 ccan/order_functions/_info                 |  33 +++++++
 ccan/order_functions/order_functions.c     |  70 +++++++++++++++
 ccan/order_functions/order_functions.h     |  73 +++++++++++++++
 ccan/order_functions/test/compile_fail_1.c |  24 +++++
 ccan/order_functions/test/compile_fail_2.c |  25 ++++++
 ccan/order_functions/test/compile_ok.c     |  19 ++++
 ccan/order_functions/test/fancy_cmp.h      |  47 ++++++++++
 ccan/order_functions/test/run.c            | 138 +++++++++++++++++++++++++++++
 15 files changed, 442 insertions(+), 30 deletions(-)
 create mode 120000 ccan/order_functions/LICENSE
 create mode 100644 ccan/order_functions/_info
 create mode 100644 ccan/order_functions/order_functions.c
 create mode 100644 ccan/order_functions/order_functions.h
 create mode 100644 ccan/order_functions/test/compile_fail_1.c
 create mode 100644 ccan/order_functions/test/compile_fail_2.c
 create mode 100644 ccan/order_functions/test/compile_ok.c
 create mode 100644 ccan/order_functions/test/fancy_cmp.h
 create mode 100644 ccan/order_functions/test/run.c

-- 
2.4.2



More information about the ccan mailing list