diff --git a/src/utils/ufd.c b/src/utils/ufd.c index 79f0a24..9cf1af3 100644 --- a/src/utils/ufd.c +++ b/src/utils/ufd.c @@ -5,10 +5,10 @@ void ufd__init(struct ufd_t* ufd, struct context_entry_t* thread) { - TAILQ_INIT(&ufd->children); ufd->thread = thread; ufd->repr = ufd, ufd->parent = NULL; + ufd->child = NULL; } @@ -19,7 +19,7 @@ void ufd__join(struct ufd_t* th1, struct ufd_t* th2) if (a != b) { - a->parent = b; + a->parent = th2; a->repr = b; } } @@ -38,9 +38,9 @@ struct ufd_t* ufd__find(struct ufd_t* th) void ufd__delete(struct ufd_t* th) { - struct ufd_t* child; - TAILQ_FOREACH(child, &th->children, link) { - child->parent = NULL; - child->repr = child; + if (th->child != NULL) + { + th->child->parent = th->child; + th->child->repr = th->child; } } diff --git a/src/utils/ufd.h b/src/utils/ufd.h index c8a8daf..b7b0522 100644 --- a/src/utils/ufd.h +++ b/src/utils/ufd.h @@ -2,15 +2,12 @@ #define _UNION_FIND_H_ #include -TAILQ_HEAD(ufd_children_t, ufd_t); - // union find delete data structure struct ufd_t { struct ufd_t* parent; struct ufd_t* repr; + struct ufd_t* child; struct context_entry_t* thread; - struct ufd_children_t children; - TAILQ_ENTRY(ufd_t) link; };