changeset 15:e2048e569891

insertLast returns now new inserted node; very dumb implementation for action_times
author meillo@marmaro.de
date Wed, 13 Feb 2008 09:57:07 +0100
parents 15e11eea1c66
children b62288419c1c
files actions.c baum.c baum.h
diffstat 3 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/actions.c	Wed Feb 13 09:16:01 2008 +0100
+++ b/actions.c	Wed Feb 13 09:57:07 2008 +0100
@@ -85,10 +85,16 @@
 
 unsigned char action_times(struct Node* node) {
 	struct Node* tp;
+	struct Node* last;
 	unsigned char i;
 	tp = node->down;
 	for (i = 0; i < node->value; i++) {
 		/* deep copy */
+		last = insertLast(node, newNode(tp->name, tp->value));
+		if (tp->down != NULL) {
+			last->down = newNode(tp->down->name, tp->down->value);
+		}
+
 	}
 	return 0;
 }
--- a/baum.c	Wed Feb 13 09:16:01 2008 +0100
+++ b/baum.c	Wed Feb 13 09:57:07 2008 +0100
@@ -58,9 +58,10 @@
 	return node;
 }
 
-void insertLast(struct Node* node, struct Node* insert) {
+struct Node* insertLast(struct Node* node, struct Node* insert) {
 	node = lastNode(node);
 	node->right = insert;
+	return insert;
 }
 
 /* delete */
--- a/baum.h	Wed Feb 13 09:16:01 2008 +0100
+++ b/baum.h	Wed Feb 13 09:57:07 2008 +0100
@@ -10,7 +10,7 @@
 
 struct Node* nextNode(struct Node* node);
 struct Node* lastNode(struct Node* node);
-void insertLast(struct Node* node, struct Node* insert);
+struct Node* insertLast(struct Node* node, struct Node* insert);
 
 
 struct Node {