我目前正在用不透明指針寫一個二叉樹結構。但是,我用Valgrind寫入了無效的內容。不透明指針valgrind
Tree.c:
struct node{
int key;
struct node *left, *right, *parent;
};
NODE nodeInit(void)
{
NODE tree = (NODE) malloc(sizeof(NODE));
tree->key = -1;
//Error with the 3 lines below
tree->right = NULL;
tree->left = NULL;
tree->parent = NULL;
return tree;
}
tree.h中:
typedef struct node* NODE;
注:我不能改變的頭文件。