I'm currently writing a binary tree structure with Opaque Pointer. However, I have Invalid writes with 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;
Note : I mustn't change the header file.