rpmdb/merge.c File Reference

#include "system.h"

Go to the source code of this file.

Defines

#define NATURAL
#define THRESHOLD   16
#define ISIZE   sizeof(int)
#define PSIZE   sizeof(unsigned char *)
#define ICOPY_LIST(src, dst, last)
#define ICOPY_ELT(src, dst, i)
#define CCOPY_LIST(src, dst, last)
#define CCOPY_ELT(src, dst, i)
#define EVAL(p)
#define swap(a, b)
#define reverse(bot, top)

Functions

static void insertionsort (unsigned char *a, size_t n, size_t size, int(*cmp)(const void *, const void *))
static void setup (unsigned char *list1, unsigned char *list2, size_t n, size_t size, int(*cmp)(const void *, const void *))
int mergesort (void *base, size_t nmemb, size_t size, int(*cmp)(const void *, const void *))
 Mergesort, same arguments as qsort(2).


Define Documentation

#define CCOPY_ELT ( src,
dst,
 ) 

Value:

do                                      \
                *dst++ = *src++;                \
        while (i -= 1)

Definition at line 74 of file merge.c.

Referenced by mergesort().

#define CCOPY_LIST ( src,
dst,
last   ) 

Value:

do                                      \
                *dst++ = *src++;                \
        while (src < last)

Definition at line 70 of file merge.c.

Referenced by mergesort().

#define EVAL (  ) 

Value:

(unsigned char **)                                      \
    ((unsigned char *)0 +                                               \
        (((unsigned char *)p + PSIZE - 1 - (unsigned char *) 0) & ~(PSIZE - 1)))

Definition at line 85 of file merge.c.

Referenced by mergesort(), and setup().

#define ICOPY_ELT ( src,
dst,
 ) 

Value:

do                                                      \
        *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE;  \
        while (i -= ISIZE)

Definition at line 65 of file merge.c.

Referenced by mergesort().

#define ICOPY_LIST ( src,
dst,
last   ) 

Value:

do                                                      \
        *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE;    \
        while(src < last)

Definition at line 61 of file merge.c.

Referenced by mergesort().

#define ISIZE   sizeof(int)

Definition at line 59 of file merge.c.

Referenced by mergesort().

#define NATURAL

Definition at line 50 of file merge.c.

#define PSIZE   sizeof(unsigned char *)

Definition at line 60 of file merge.c.

Referenced by mergesort().

#define reverse ( bot,
top   ) 

Value:

{                               \
        s = top;                                        \
        do {                                            \
                i = size;                               \
                do {                                    \
                        tmp = *bot; *bot++ = *s; *s++ = tmp; \
                } while (--i);                          \
                s -= size2;                             \
        } while(bot < s);                               \
}

Definition at line 97 of file merge.c.

Referenced by setup().

#define swap ( a,
 ) 

Value:

{                                       \
                s = b;                                  \
                i = size;                               \
                do {                                    \
                        tmp = *a; *a++ = *s; *s++ = tmp; \
                } while (--i);                          \
                a -= size;                              \
        }

Definition at line 89 of file merge.c.

Referenced by insertionsort(), and setup().

#define THRESHOLD   16

Definition at line 51 of file merge.c.

Referenced by setup().


Function Documentation

static void insertionsort ( unsigned char *  a,
size_t  n,
size_t  size,
int(*)(const void *, const void *)  cmp 
) [static]

Definition at line 113 of file merge.c.

References swap.

Referenced by setup().

int mergesort ( void *  base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  cmp 
)

Mergesort, same arguments as qsort(2).

Definition at line 208 of file merge.c.

References CCOPY_ELT, CCOPY_LIST, errno, EVAL, ICOPY_ELT, ICOPY_LIST, ISIZE, PSIZE, and setup().

Referenced by rpmdbSortIterator().

static void setup ( unsigned char *  list1,
unsigned char *  list2,
size_t  n,
size_t  size,
int(*)(const void *, const void *)  cmp 
) [static]

Definition at line 136 of file merge.c.

References EVAL, insertionsort(), reverse, swap, and THRESHOLD.

Referenced by mergesort().


Generated on Fri Oct 12 08:44:56 2007 for rpm by  doxygen 1.5.2