int Tree_Dump (node* my_node, char* tab) { assert(my_node); assert(tab); Node_Dump (my_node); fprintf (LOG, "%s|\n", tab); fprintf (LOG, "%s" "R---", tab); char new_tab[TMPLEN] = {}; sprintf(new_tab, "%s| ", tab); if (my_node -> right == NULL) fprintf(LOG, "[nil]\n"); else Tree_Dump (my_node -> right, new_tab); fprintf (LOG, "%s|\n", tab); fprintf (LOG, "%s" "L---", tab); sprintf(new_tab, "%s ", tab); if (my_node -> left == NULL) fprintf (LOG, "[nil]\n"); else Tree_Dump (my_node -> left, new_tab); return HAPPY; }
void Node_Dump (FILE* outstream, tree_t* node, unsigned int depth) { ASSERT (outstream); ASSERT (node); register unsigned int i = 0; FORMAT_DUMP; fprintf (outstream, "("); if (node->left) { Node_Dump (outstream, node->left, depth + 1); } else { FORMAT_DUMP; fprintf (outstream, "\tnil"); } FORMAT_DUMP; fprintf (outstream, "\t%lg | Size: %d | Address: [%08x], Left: [%08x], Right: [%08x] " "Parent: [%08x], Type: %d, %s", node->info, node->size, (int) node, (int) node->left, (int) node->right, (int) node->parent, node->type, (Node_Is_OK (node, NULL) == NODE_OK)? "ok" : "ERROR!"); if (node->right) { Node_Dump (outstream, node->right, depth + 1); } else { FORMAT_DUMP; fprintf (outstream, "\tnil"); } FORMAT_DUMP; fprintf (outstream, ")"); }
void Tree_Dump (FILE* outstream, root_t* tree) { ASSERT (outstream); fprintf (outstream, "Dump of tree [%08x] - %s\n", (int) tree, (Tree_Is_OK (tree) == TREE_OK)? "ok" : "ERROR!"); fprintf (outstream, "size = %d", tree->size); Node_Dump (outstream, tree->root, 0); fprintf (outstream, "\nDump of tree [%08x] finished.\n\n", (int) tree); }