Hi Everyone,
I have a linked list I'm working on to keep track of worker nodes
(worker nodes are a client that handles requests for a server).
typedef struct Node
{
....
char* address; //!< address of worker
struct Node* next; //!< Next Node
struct Node* prev; //!< Previous Node
} Node;
Node * gTopNode = NULL;
I have a section of code that looks to me like it may contain an
error.
Given the following function (trimmed for brevity ...)
///Create a new node and add it to the end of the list
Node* CreateNode(char* address,Node* pTopNode)
{
....
Node* pNode = NodeListFindNode(address,pTopNode);
if(pNode == NULL)
{
pNode = (Node*) calloc (1,sizeof(Node));
pNode->address = address;
....
}
.....
}
It is called as follows.
int module_init(int argc, char* argv[])
{
....
gTopNode = NodeListCreateNode("127.0.0.1",gTopNode);
....
if(gTopNode != NULL)
return OK;
else
return MODULE_FAILED
}
So my question is what will happen to gTopNode->address after
module_init returns.
A lot of places will reference it since it's a global starting point.
Will the value of address still be "127.0.0.1" or will it end up
deallocated?
Thanks in advance!