/* $Id$ */
-/* Release $Name$ */
-
/* qsort( void *, size_t, size_t, int(*)( const void *, const void * ) )
This file is part of the Public Domain C Library (PDCLib).
*/
/* Wrapper for _PDCLIB_memswp protects against multiple argument evaluation. */
-static inline void memswp( char * i, char * j, unsigned int size )
+static inline void memswp( char * i, char * j, size_t size )
{
_PDCLIB_memswp( i, j, size );
}
{
char * i;
char * j;
- size_t thresh = T * size;
- char * base_ = (char *)base;
- char * limit = base_ + nmemb * size;
+ _PDCLIB_size_t thresh = T * size;
+ char * base_ = (char *)base;
+ char * limit = base_ + nmemb * size;
PREPARE_STACK;
for ( ;; )
{
- if ( limit - base_ > thresh ) /* QSort for more than T elements. */
+ if ( (size_t)( limit - base_ ) > thresh ) /* QSort for more than T elements. */
{
/* We work from second to last - first will be pivot element. */
i = base_ + size;
#include <string.h>
#include <limits.h>
-int compare( const void * left, const void * right )
+static int compare( const void * left, const void * right )
{
return *( (unsigned char *)left ) - *( (unsigned char *)right );
}
-int main()
+int main( void )
{
char presort[] = { "shreicnyjqpvozxmbt" };
char sorted1[] = { "bcehijmnopqrstvxyz" };
char sorted2[] = { "bticjqnyozpvreshxm" };
char s[19];
- BEGIN_TESTS;
strcpy( s, presort );
qsort( s, 18, 1, compare );
TESTCASE( strcmp( s, sorted1 ) == 0 );