int destroy_node(tree *pTree, char *words) { node *search_result = NULL, *temp = NULL; search_result = (node *)search_node_by_content(pTree, words); if(search_result != NULL && search_result->left == NULL \ && search_result->right == NULL) { delete_leaf_node(pTree, search_result); } else if(search_result != NULL && (search_result->left != NULL \ || search_result->right != NULL)) { if(search_result->wordsNum == 1) { relink_tree(pTree, search_result); } else { search_result->wordsNum--; } } else { printf("No this data in the tree\n"); return -1; } traverse2(pTree); return 0; }
int exec_pipe(t_tab *tab, t_btree **tree, int status, t_pid **pid) { int n; n = 0; (void)status; fill_pid(pid, 1); if (pipe(tab->pipefd[tab->pipe % 2]) == -1) return (-1); if (!((*pid)->nbr = fork())) return (fork_pipe(tab, tree, pid, n)); if ((close(tab->pipefd[tab->pipe % 2][1])) == -1) return (-1); fd_is_on(tab, CLOSE); if (tab) { tab->sid = (tab->sid == 0) ? (*pid)->nbr : tab->sid; tab->pipe++; } relink_tree(tree); return (0); }