Example #1
0
void appendChild(Node *node, Node *chd) {
  Node *lc;

  if (!chd)
    return;

  lc = lastChild(node);
  if (!lc) {
    set_firstChild(node, chd);
  } else {
    set_nextSibling(lc, chd);
    set_previousSibling(chd, lc);
  }
  while (chd) {
    lc = chd;
    set_parentNode(chd, node);
    chd = nextSibling(chd);
  }
  set_lastChild(node, lc);
}
Example #2
0
void
deleteNode(Node *n) {
  Node *parent;
  Node *prev;
  Node *next;

  parent = parentNode(n);
  prev = previousSibling(n);
  next = nextSibling(n);
  if (prev) {
    set_nextSibling(prev,next);
  } else {
    if (parent) {
      set_firstChild(parent,next);
    }
  }
  if (next) {
    set_previousSibling(next,prev);
  } else {
    if (parent) {
      set_lastChild(parent,prev);
    }
  }
}