diff --git a/src/rbtree2.c b/src/rbtree2.c index 2d60e81..23d8163 100644 --- a/src/rbtree2.c +++ b/src/rbtree2.c @@ -1,10 +1,12 @@ #include +#include #include "class.h" #include "commons.h" #include "utils/memory.h" #include "tree.h" +#include "utils/memory.h" #define NVALUES 10 @@ -14,54 +16,75 @@ insertCompare(const void * tval, const void * search) return *(const int *)tval - *(const int *)search; } +void +freeNode(const void * data, const int depth) +{ + printf("now free %d at %p\n", *(int*)data, data); + MEM_FREE(data); +} + void printNode(const void * _node, const int depth) { - //Tree node = (Tree)_node; - //int value = *(int *)node->data; - int value = *(int *)_node; + Tree node = (Tree)_node; + int value = *(int *)node->data; int i; - printf("%010d(%02d)", value, depth); + for (i=1; i<7; i++) i<=depth?printf("-"):printf(" "); + printf("%p:%d p:%p l:%p r:%p\n", + node, value, node->parent, node->left, node->right); // printf("%s %010d(%02d)", // (node->color==rbRed)?"R":"B", // value, // depth); - for (i=0; i