Hello all,
Info: I am using Pelles C compiler.
Some code first:
Following is the linked list structure I am using.
typedef struct _NODESTRUCT
{
void* data;
struct _NODESTRUCT* next;
} NODESTRUCT, *PNODESTRUCT;
Method to add a new node to linked list:
PNODESTRUCT AppendNode(PNODESTRUCT rootNode, void *data)
{
PNODESTRUCT tempNode;
PNODESTRUCT currentNode;
ginodestructsize = sizeof(NODESTRUCT);
if(!rootNode)
{
rootNode = (PNODESTRUCT)malloc(ginodestructsize);
currentNode = rootNode;
currentNode->data = data;
}
else
{
currentNode =GetLastNode(rootNode);
tempNode = (PNODESTRUCT)malloc(sizeof(NODESTRUCT));
tempNode->data = data;
currentNode->next = tempNode;
}
return currentNode;
}
Now a call to this method:
PNODESTRUCT rootnode;
PNODESTRUCT currentnode;
rootnode = NULL;
currentnode = AppendNode(rootnode, NULL);
Right after the first call I expect rootnode to have some value as I am trying to achieve from the method AppendNode. But even after AppendNode call, rootnode is NULL.
Any guesses why? Any help will be appreciated :)