NodePtr node = (NodePtr)malloc(sizeof(NodePtr));
Isn't doing what you are thinking. It's allocate space to hold a pointer same as sizeof(int*
), it's 4
bytes on 32-bit machine, usually.
You need to do NodePtr node = malloc(sizeof(struct onode));
instead of.
data
member should be result to a malloc(sizeof(struct order));