X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Ftest%2FDo.c;h=9a6135f934d2aae94963722690360edb15efed01;hb=fa1f1f0c232a7290b5705f325bdc5d614a15f630;hp=43b826e4de183781b69f900e8ff9ce45d241f28d;hpb=380be6db4ec0f9d22668032077e7e5b34efe07d0;p=libfirm diff --git a/ir/be/test/Do.c b/ir/be/test/Do.c index 43b826e4d..9a6135f93 100644 --- a/ir/be/test/Do.c +++ b/ir/be/test/Do.c @@ -12,58 +12,58 @@ typedef struct Node Node; typedef struct Data { - const char *name; - const char *addr; - int account1; - int account2; - int account3; - Node *found; + const char *name; + const char *addr; + int account1; + int account2; + int account3; + Node *found; } Data; struct Node { - Data mydata; - int mykey; - Node *son1; - Node *son2; - Node *son3; - Node *son4; + Data mydata; + int mykey; + Node *son1; + Node *son2; + Node *son3; + Node *son4; }; static int Node_count; static Node *new_node(int depth) { - Node *res; - - res = (void *)malloc(sizeof(*res)); - res->mykey = Node_count++; /* @@@ Want Random number */ - - if (depth > 1) { - res->son1 = new_node(depth-1); - res->son2 = new_node(depth-1); - /*res->son3 = new_node(depth-1); - res->son4 = new_node(depth-1);*/ - } else { - res->son1 = NULL; - res->son2 = NULL; - res->son3 = NULL; - res->son4 = NULL; - } - return res; + Node *res; + + res = (void *)malloc(sizeof(*res)); + res->mykey = Node_count++; /* @@@ Want Random number */ + + if (depth > 1) { + res->son1 = new_node(depth-1); + res->son2 = new_node(depth-1); + res->son3 = new_node(depth-1); + res->son4 = new_node(depth-1); + } else { + res->son1 = NULL; + res->son2 = NULL; + res->son3 = NULL; + res->son4 = NULL; + } + return res; } static int find_max(Node *n) { - if (n->son1 == NULL) { - return n->mykey; - } else { - int max = find_max(n->son1); - int max2 = find_max(n->son2); - if (max2 > max) max = max2; - /*max2 = find_max(n->son3); - if (max2 > max) max = max2; - max2 = find_max(n->son4); - if (max2 > max) max = max2;*/ - return max; - } + if (n->son1 == NULL) { + return n->mykey; + } else { + int max = find_max(n->son1); + int max2 = find_max(n->son2); + if (max2 > max) max = max2; + /*max2 = find_max(n->son3); + if (max2 > max) max = max2; + max2 = find_max(n->son4); + if (max2 > max) max = max2;*/ + return max; + } } @@ -71,26 +71,26 @@ static int find_max(Node *n) { static Node *root; /* root of the tree to search */ static void alloc (int depth) { - root = new_node(depth); + root = new_node(depth); } static void search (void) { - printf(" Max = %d\n", find_max(root)); + printf(" Max = %d\n", find_max(root)); } int main(int argc, char *argv[]) { - int depth; - - printf("Do.c:\n"); - if (argc <= 1) { - printf("Usage: Do n\nGive search tree depth!\n"); - printf("10 is a good value, 12 too much.\n"); - printf("Continuing with default value 9.\n"); - depth = 9; - } else { - depth = atoi(argv[1]); - } - alloc(depth); - search(); - - return 0; + int depth; + + printf("Do.c:\n"); + if (argc <= 1) { + printf("Usage: Do n\nGive search tree depth!\n"); + printf("10 is a good value, 12 too much.\n"); + printf("Continuing with default value 9.\n"); + depth = 9; + } else { + depth = atoi(argv[1]); + } + alloc(depth); + search(); + + return 0; }