Example #1
0
ParseNode* merge_tree(void *malloc_pool, ObItemType node_tag, ParseNode* source_tree)
{
  int index = 0;
  int num = 0;
  ParseNode* node;
  if(source_tree == NULL)
    return NULL;
  num = count_child(source_tree);
  node = new_node(malloc_pool, node_tag, num);
  merge_child(node, source_tree, &index);
  assert(index == num);
  return node;
}
Example #2
0
int count_child(ParseNode* root)
{
  if(root == 0) return 0;

  int count = 0;
  if(root->type_ != T_LINK_NODE)
  {
    return 1;
  }
  int i;
  for(i = 0; i < root->num_child_; ++i)
  {
    count += count_child(root->children_[i]);
  }
  return count;
}