|
From: Nicholas N. <nj...@ca...> - 2003-11-13 21:51:17
|
CVS commit by nethercote:
Remove local shellshort function, use the standard VG_(ssort).
M +8 -52 vg_symtab2.c 1.56
--- valgrind/coregrind/vg_symtab2.c #1.55:1.56
@@ -384,53 +384,9 @@ void safeCopy ( UChar* dst, UInt maxlen,
/*------------------------------------------------------------*/
-static void shellsort(void *base, UInt nmemb, UInt sz, Int (*compare)(void *a, void *b))
-{
- /* Magic numbers due to Janet Incerpi and Robert Sedgewick. */
- static const Int incs[16] = { 1, 3, 7, 21, 48, 112, 336, 861, 1968,
- 4592, 13776, 33936, 86961, 198768,
- 463792, 1391376 };
- Int lo = 0;
- Int hi = nmemb-1;
- Int bigN;
- Int hp;
- Char *cp = (Char *)base;
- Char tmp[sz];
-
- bigN = hi - lo + 1;
- if (bigN < 2)
- return;
- hp = 0;
- while (hp < 16 && incs[hp] < bigN)
- hp++;
- hp--;
- vg_assert(0 <= hp && hp < 16);
-
- for (; hp >= 0; hp--) {
- Int i, h;
-
- h = incs[hp];
- i = lo + h;
- for (i = lo+h; i <= hi; i++) {
- Int j;
- VG_(memcpy)(&tmp, &cp[i * sz], sz);
-
- j = i;
- while ((*compare)((void *)&cp[(j-h) * sz], (void *)&tmp) > 0) {
- VG_(memcpy)(&cp[j * sz], &cp[(j-h) * sz], sz);
- j = j - h;
- if (j <= (lo + h - 1))
- break;
- }
- VG_(memcpy)(&cp[j * sz], &tmp, sz);
- }
- }
-}
-
/* Sort the symtab by starting address, and emit warnings if any
- symbols have overlapping address ranges. We use that old chestnut,
- shellsort. Mash the table around so as to establish the property
- that addresses are in order and the ranges to not overlap. This
- facilitates using binary search to map addresses to symbols when we
- come to query the table.
+ symbols have overlapping address ranges. Mash the table around so as to
+ establish the property that addresses are in order and the ranges to not
+ overlap. This facilitates using binary search to map addresses to
+ symbols when we come to query the table.
*/
static Int compare_RiSym(void *va, void *vb) {
@@ -453,5 +409,5 @@ void canonicaliseSymtab ( SegInfo* si )
return;
- shellsort(si->symtab, si->symtab_used, sizeof(*si->symtab), compare_RiSym);
+ VG_(ssort)(si->symtab, si->symtab_used, sizeof(*si->symtab), compare_RiSym);
cleanup_more:
@@ -581,5 +537,5 @@ void canonicaliseScopetab ( SegInfo* si
/* Sort by start address. */
- shellsort(si->scopetab, si->scopetab_used, sizeof(*si->scopetab),
+ VG_(ssort)(si->scopetab, si->scopetab_used, sizeof(*si->scopetab),
compare_ScopeRange);
@@ -653,5 +609,5 @@ void canonicaliseLoctab ( SegInfo* si )
/* Sort by start address. */
- shellsort(si->loctab, si->loctab_used, sizeof(*si->loctab), compare_RiLoc);
+ VG_(ssort)(si->loctab, si->loctab_used, sizeof(*si->loctab), compare_RiLoc);
/* If two adjacent entries overlap, truncate the first. */
|