vppinfra: finish deprecating qsort.c
Minor change to vec_sort_with_function(...): don't depend on the qsort
implementation to deal with null, zero-long, or 1-long vectors
Type: fix
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I7bd7b0421673d2a025363089562aa7c6266fba66
(cherry picked from commit f593b57920
)
This commit is contained in:

committed by
Andrew Yourtchenko

parent
eaef2de7f9
commit
3b49dc6cc8
@ -974,12 +974,16 @@ do { \
|
|||||||
|
|
||||||
/** \brief Sort a vector using the supplied element comparison function
|
/** \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 vec vector to sort
|
||||||
@param f comparison function
|
@param f comparison function
|
||||||
*/
|
*/
|
||||||
#define vec_sort_with_function(vec,f) \
|
#define vec_sort_with_function(vec,f) \
|
||||||
do { \
|
do { \
|
||||||
qsort (vec, vec_len (vec), sizeof (vec[0]), (void *) (f)); \
|
if (vec_len (vec) > 1) \
|
||||||
|
qsort (vec, vec_len (vec), sizeof (vec[0]), (void *) (f)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/** \brief Make a vector containing a NULL terminated c-string.
|
/** \brief Make a vector containing a NULL terminated c-string.
|
||||||
|
Reference in New Issue
Block a user