diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-13 16:13:29 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-13 16:13:29 +0200 |
commit | 105f520c7e2c40939f78be061e143687dadfa0fb (patch) | |
tree | 40a9921a785ea69f405a69479086c19208159449 /thread.c | |
parent | 435d5a5a8967cb213a8de8cbebf2657b3aa2a9d0 (diff) | |
download | mblaze-105f520c7e2c40939f78be061e143687dadfa0fb.tar.gz mblaze-105f520c7e2c40939f78be061e143687dadfa0fb.tar.xz mblaze-105f520c7e2c40939f78be061e143687dadfa0fb.zip |
thread: try to keep relative order from input
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/thread.c b/thread.c index 95bfb53..aa2d377 100644 --- a/thread.c +++ b/thread.c @@ -194,16 +194,15 @@ out: c->parent = parent; -/* - not needed with above checks? - for (r = parent->child; r; r = r->next) { - // check if we are already a child of the correct parent - if (r == c) - goto out2; + // add at the end + for (r = parent->child; r && r->next; r = r->next) + ; + if (!r) { + parent->child = c; + } else { + r->next = c; + c->next = 0; } -*/ - c->next = parent->child; - parent->child = c; out2: // someone said our parent was our child, a lie @@ -222,7 +221,7 @@ find_root(const void *nodep, const VISIT which, const int depth) { (void)depth; - if (which == postorder || which == leaf) { + if (which == preorder || which == leaf) { struct container *c = *(struct container **)nodep; if (!c->parent) { |