diff options
-rw-r--r-- | extras/deprecated/vppinfra/qsort.c (renamed from src/vppinfra/qsort.c) | 0 | ||||
-rw-r--r-- | src/vppinfra/vec.h | 10 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/vppinfra/qsort.c b/extras/deprecated/vppinfra/qsort.c index 145ae40fe91..145ae40fe91 100644 --- a/src/vppinfra/qsort.c +++ b/extras/deprecated/vppinfra/qsort.c diff --git a/src/vppinfra/vec.h b/src/vppinfra/vec.h index 9054eaa5e57..e9836107799 100644 --- a/src/vppinfra/vec.h +++ b/src/vppinfra/vec.h @@ -1040,12 +1040,16 @@ do { \ /** \brief Sort a vector using the supplied element comparison function + Does not depend on the underlying implementation to deal correctly + with null, zero-long, or 1-long vectors + @param vec vector to sort @param f comparison function */ -#define vec_sort_with_function(vec,f) \ -do { \ - qsort (vec, vec_len (vec), sizeof (vec[0]), (void *) (f)); \ +#define vec_sort_with_function(vec,f) \ +do { \ + if (vec_len (vec) > 1) \ + qsort (vec, vec_len (vec), sizeof (vec[0]), (void *) (f)); \ } while (0) /** \brief Make a vector containing a NULL terminated c-string. |