Setting uninitialized values
Uninitialized values should be set to NULL to aid in memory deallocation at cleanup time.
This commit is contained in:
parent
da6490ac7f
commit
a180a63160
3 changed files with 18 additions and 12 deletions
18
node/node.c
18
node/node.c
|
@ -46,6 +46,11 @@ struct Node * Create_Empty_Node()
|
||||||
{
|
{
|
||||||
struct Node * N;
|
struct Node * N;
|
||||||
N = (struct Node *)malloc(sizeof(struct Node));
|
N = (struct Node *)malloc(sizeof(struct Node));
|
||||||
|
N->data_size = 0;
|
||||||
|
N->cached = NULL;
|
||||||
|
N->data = NULL;
|
||||||
|
N->encoded = NULL;
|
||||||
|
N->link_ammount = 0;
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,16 +72,14 @@ int Node_Set_Data(struct Node * N, unsigned char * Data)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Node_Get_Data
|
/***
|
||||||
* Gets data from a node
|
* Gets data from a node
|
||||||
* @param Node: = The node you want to get data from. (unsigned char *)
|
* @param Node The node you want to get data from. (unsigned char *)
|
||||||
* Returns data of node.
|
* @returns data of node.
|
||||||
*/
|
*/
|
||||||
unsigned char* Node_Get_Data(struct Node* N)
|
unsigned char* Node_Get_Data(struct Node* N)
|
||||||
{
|
{
|
||||||
unsigned char * DATA;
|
return N->data;
|
||||||
DATA = N->data;
|
|
||||||
return DATA;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,6 +221,9 @@ struct Node * N_Create_From_Link(struct Link * mylink)
|
||||||
mynode->link_ammount = 0;
|
mynode->link_ammount = 0;
|
||||||
mynode->link_ammount++;
|
mynode->link_ammount++;
|
||||||
mynode->links[0] = malloc(sizeof(struct Link));
|
mynode->links[0] = malloc(sizeof(struct Link));
|
||||||
|
mynode->data_size = 0;
|
||||||
|
mynode->data = NULL;
|
||||||
|
mynode->cached = NULL;
|
||||||
memcpy(mynode->links[0], mylink, sizeof(struct Link));
|
memcpy(mynode->links[0], mylink, sizeof(struct Link));
|
||||||
return mynode;
|
return mynode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,5 +38,5 @@ int test_node() {
|
||||||
Free_Link(mylink2);
|
Free_Link(mylink2);
|
||||||
Free_Link(ResultLink);
|
Free_Link(ResultLink);
|
||||||
Node_Delete(Mynode);
|
Node_Delete(Mynode);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue