src/lib/tree.c
static TREE_NODE *search_and_insert_tree_node(char *fname, int type,
               TREE_ROOT *root, TREE_NODE *parent)
{
   TREE_NODE *node, *found_node;
   node = new_tree_node(root);
   node->fname = fname;
   found_node = (TREE_NODE *)parent->child.insert(node, node_compare);
   if (found_node != node) {          /* already in list */
      free_tree_node(root);           /* free node allocated above */
      found_node->inserted = false;
      return found_node;
   }
   /* It was not found, but is now inserted */
   node->fname_len = strlen(fname);
   node->fname = tree_alloc(root, node->fname_len + 1);
   strcpy(node->fname, fname);
   node->parent = parent;
   node->type = type;
   /* Maintain a linear chain of nodes */
   if (!root->first) {
      root->first = node;
      root->last = node;
   } else {
      root->last->next = node;
      root->last = node;
   }
   node->inserted = true;             /* inserted into tree */
   return node;

}
/*
 *  See if the fname already exists. If not insert a new node for it.
 */
See if the fname already exists. If not insert a new node for it.
See if the fname already exists . If not insert a new node for it .
static TREE_NODE *search_and_insert_tree_node(char *fname, int type,
               TREE_ROOT *root, TREE_NODE *parent)
{
   TREE_NODE *node, *found_node;
   node = new_tree_node(root);
   node->fname = fname;
   found_node = (TREE_NODE *)parent->child.insert(node, node_compare);
   if (found_node != node) {          
      free_tree_node(root);           
      found_node->inserted = false;
      return found_node;
   }
   node->fname_len = strlen(fname);
   node->fname = tree_alloc(root, node->fname_len + 1);
   strcpy(node->fname, fname);
   node->parent = parent;
   node->type = type;
   if (!root->first) {
      root->first = node;
      root->last = node;
   } else {
      root->last->next = node;
      root->last = node;
   }
   node->inserted = true;             
   return node;
}
static TREE_NODE * search_and_insert_tree_node ( char * fname , int type , TREE_ROOT * root , TREE_NODE * parent ) { TREE_NODE * node , * found_node ; node = new_tree_node ( root ) ; node -> fname = fname ; found_node = ( TREE_NODE * ) parent -> child . insert ( node , node_compare ) ; if ( found_node != node ) { free_tree_node ( root ) ; found_node -> inserted = false ; return found_node ; } node -> fname_len = strlen ( fname ) ; node -> fname = tree_alloc ( root , node -> fname_len + 1 ) ; strcpy ( node -> fname , fname ) ; node -> parent = parent ; node -> type = type ; if ( ! root -> first ) { root -> first = node ; root -> last = node ; } else { root -> last -> next = node ; root -> last = node ; } node -> inserted = true ; return node ; }
See if the fname already exists.
See if the fname already exists .
/* already in list */ /* free node allocated above */ /* It was not found, but is now inserted */ /* Maintain a linear chain of nodes */ /* inserted into tree */