fix broken thread tree traversal in machine.cpp

This commit is contained in:
Joel Dice 2008-04-11 16:48:05 -06:00
parent f7a79f4874
commit 04c3abc967

View File

@ -22,15 +22,9 @@ namespace {
bool bool
find(Thread* t, Thread* o) find(Thread* t, Thread* o)
{ {
if (t == o) return true; return (t == o)
or (t->peer and find(t->peer, o))
for (Thread* p = t->peer; p; p = p->peer) { or (t->child and find(t->child, o));
if (p == o) return true;
}
if (t->child) return find(t->child, o);
return false;
} }
void void
@ -48,11 +42,7 @@ count(Thread* t, Thread* o)
unsigned c = 0; unsigned c = 0;
if (t != o) ++ c; if (t != o) ++ c;
if (t->peer) c += count(t->peer, o);
for (Thread* p = t->peer; p; p = p->peer) {
c += count(p, o);
}
if (t->child) c += count(t->child, o); if (t->child) c += count(t->child, o);
return c; return c;
@ -62,12 +52,8 @@ Thread**
fill(Thread* t, Thread* o, Thread** array) fill(Thread* t, Thread* o, Thread** array)
{ {
if (t != o) *(array++) = t; if (t != o) *(array++) = t;
if (t->peer) fill(t->peer, o, array);
for (Thread* p = t->peer; p; p = p->peer) { if (t->child) fill(t->child, o, array);
array = fill(p, o, array);
}
if (t->child) array = fill(t->child, o, array);
return array; return array;
} }