|
From: <sv...@va...> - 2006-01-07 22:33:53
|
Author: sewardj
Date: 2006-01-07 22:33:45 +0000 (Sat, 07 Jan 2006)
New Revision: 5505
Log:
Make this test 64-bit clean.
Modified:
trunk/memcheck/tests/oset_test.c
Modified: trunk/memcheck/tests/oset_test.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/oset_test.c 2006-01-07 21:52:50 UTC (rev 5504)
+++ trunk/memcheck/tests/oset_test.c 2006-01-07 22:33:45 UTC (rev 5505)
@@ -34,31 +34,32 @@
#define NN 1000 // Size of OSets being created
=20
//----------------------------------------------------------------------=
-----
-// Int example
+// Word example
//----------------------------------------------------------------------=
-----
=20
-// This example shows that an element can be a single value (in this cas=
e an
-// Int), in which case the element is also the key.
+// This example shows that an element can be a single value (in this
+// case a Word), in which case the element is also the key.
=20
__attribute__((unused))
-static Char *intToStr(void *p)
+static Char *wordToStr(void *p)
{
- static char buf[16];
- sprintf(buf, "%d", *(Int*)p);
+ static char buf[32];
+ sprintf(buf, "%ld", *(Word*)p);
return buf;
}
=20
__attribute__((unused))
-static Int intCmp(void* vkey, void* velem)
+static Word wordCmp(void* vkey, void* velem)
{
- return *(Int*)vkey - *(Int*)velem;
+ return *(Word*)vkey - *(Word*)velem;
}
=20
void example1(void)
{
- Int i, v, n, prev;
- Int* vs[NN];
- Int *pv;
+ Int i, n;
+ Word v, prev;
+ Word* vs[NN];
+ Word *pv;
=20
// Create a static OSet of Ints. This one uses fast (built-in)
// comparisons.
@@ -76,15 +77,15 @@
// Create some elements, with gaps (they're all even) but no dups,
// and shuffle them randomly.
for (i =3D 0; i < NN; i++) {
- vs[i] =3D VG_(OSet_AllocNode)(oset1, sizeof(Int));
+ vs[i] =3D VG_(OSet_AllocNode)(oset1, sizeof(Word));
*(vs[i]) =3D 2*i;
}
for (i =3D 0; i < NN; i++) {
- Int r1 =3D random() % NN;
- Int r2 =3D random() % NN;
- Int* tmp=3D vs[r1];
- vs[r1] =3D vs[r2];
- vs[r2] =3D tmp;
+ Word r1 =3D random() % NN;
+ Word r2 =3D random() % NN;
+ Word* tmp=3D vs[r1];
+ vs[r1] =3D vs[r2];
+ vs[r2] =3D tmp;
}
=20
// Insert the elements
@@ -124,7 +125,7 @@
prev =3D -1;
VG_(OSet_ResetIter)(oset1);
while ( (pv =3D VG_(OSet_Next)(oset1)) ) {
- Int curr =3D *pv;
+ Word curr =3D *pv;
assert(prev < curr);=20
prev =3D curr;
n++;
@@ -179,7 +180,7 @@
}
=20
// Print the list
- OSet_Print(oset1, "foo", intToStr);
+ OSet_Print(oset1, "foo", wordToStr);
=20
// Destroy the OSet
VG_(OSet_Destroy)(oset1, NULL);
|