Use size_t.

Inspired by:	OpenBSD src/lib/libc/stdlib/qsort.c,v 1.11
This commit is contained in:
Xin LI 2017-05-19 04:44:14 +00:00
parent ae0669e390
commit a3f893fc61

View file

@ -41,7 +41,7 @@ typedef int cmp_t(void *, const void *, const void *);
typedef int cmp_t(const void *, const void *);
#endif
static inline char *med3(char *, char *, char *, cmp_t *, void *);
static inline void swapfunc(char *, char *, int, int, int);
static inline void swapfunc(char *, char *, size_t, int, int);
#define MIN(a, b) ((a) < (b) ? a : b)
@ -49,7 +49,7 @@ static inline void swapfunc(char *, char *, int, int, int);
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
*/
#define swapcode(TYPE, parmi, parmj, n) { \
long i = (n) / sizeof (TYPE); \
size_t i = (n) / sizeof (TYPE); \
TYPE *pi = (TYPE *) (parmi); \
TYPE *pj = (TYPE *) (parmj); \
do { \
@ -64,7 +64,7 @@ static inline void swapfunc(char *, char *, int, int, int);
es % sizeof(TYPE) ? 2 : es == sizeof(TYPE) ? 0 : 1;
static inline void
swapfunc( char *a, char *b, int n, int swaptype_long, int swaptype_int)
swapfunc(char *a, char *b, size_t n, int swaptype_long, int swaptype_int)
{
if (swaptype_long <= 1)
swapcode(long, a, b, n)