comparison actions.c @ 55:6279e5b14d9e

added error handling for fopen and malloc; code cleanups
author meillo@marmaro.de
date Sun, 16 Mar 2008 10:40:53 +0100
parents 036779d5da75
children 21ff1783f640
comparison
equal deleted inserted replaced
54:6e46b106c334 55:6279e5b14d9e
64 64
65 unsigned char action_sum(struct Node* node) { 65 unsigned char action_sum(struct Node* node) {
66 struct Node* tp; 66 struct Node* tp;
67 67
68 node->value = 0; 68 node->value = 0;
69 tp = node->down; 69 for (tp = node->down; tp != NULL; tp = tp->right) {
70 while (tp != NULL) {
71 node->value += action(tp); 70 node->value += action(tp);
72 tp = tp->right;
73 } 71 }
74 return node->value; 72 return node->value;
75 } 73 }
76 74
77 75
100 } 98 }
101 99
102 100
103 unsigned char action_times(struct Node* node) { 101 unsigned char action_times(struct Node* node) {
104 unsigned char i; 102 unsigned char i;
103
105 for (i = 0; i < node->value; i++) { 104 for (i = 0; i < node->value; i++) {
106 insertLast(node, copyTree(node->down)); 105 insertLast(node, copyTree(node->down));
107 } 106 }
108 return 0; 107 return 0;
109 } 108 }