diff --git a/bintree.c b/bintree.c index 294ac6d..1b8aa4c 100644 --- a/bintree.c +++ b/bintree.c @@ -66,15 +66,21 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc // push the top node and push all its left nodes. void *nextTreeData(TreeNode *root) { + if(root == NULL) + { + + } + stackNode.top(root); } // Releases all memory resources (including data copies). void clearTree(TreeNode *root) { if (root == NULL) + { return; - + } // Erst linken Knoten löschen clearTree(root->left); diff --git a/stack.c b/stack.c index e3a90d4..916ac51 100644 --- a/stack.c +++ b/stack.c @@ -10,7 +10,17 @@ // Pushes data as pointer onto the stack. StackNode *push(StackNode *stack, void *data) { - + if(stack && data){ + StackNode *t = (StackNode *)malloc(sizeof(StackNode)); + if(!t) + { + return NULL; //Speicherfehler + } + t->prev = stack; + t->data = data; + return t; + } + return NULL; } // Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be diff --git a/stack.h b/stack.h index a2b8a17..e962b2b 100644 --- a/stack.h +++ b/stack.h @@ -10,8 +10,7 @@ The latest element is taken from the stack. */ //TODO: passenden Datentyp als struct anlegen typedef{ int* data; - unsigned int *fol; - unsigned int *prev; + struct StackNode *prev; }StackNode; // Pushes data as pointer onto the stack.