aboutsummaryrefslogtreecommitdiff
path: root/sys/libbio/phylo.c
blob: 8033e35da0fcccb86d6846e0401d2cc74b1a3b5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <u.h>
#include <libn.h>
#include <libbio.h>

error
phylo·addchild(bio·Node* parent, bio·Node* child)
{
    bio·Node *it, *sibling;
    if (parent->nchild < 2) {
        parent->child[parent->nchild++] = child;
    } else {
        for (it = parent->child[1]->sibling; it != nil; it = it->sibling) {
            sibling = it;
        }
        sibling->sibling = child;
        parent->nchild++;
    }

    return 0;
}