Setting uninitialized values

Uninitialized values should be set to NULL to aid in memory deallocation
at cleanup time.
This commit is contained in:
John Jones 2016-12-05 18:17:17 -05:00
parent da6490ac7f
commit a180a63160
3 changed files with 18 additions and 12 deletions

View file

@ -46,6 +46,11 @@ struct Node * Create_Empty_Node()
{
struct Node * N;
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;
}
@ -67,16 +72,14 @@ int Node_Set_Data(struct Node * N, unsigned char * Data)
return 1;
}
/*Node_Get_Data
/***
* Gets data from a node
* @param Node: = The node you want to get data from. (unsigned char *)
* Returns data of node.
* @param Node The node you want to get data from. (unsigned char *)
* @returns data of node.
*/
unsigned char* Node_Get_Data(struct Node* N)
{
unsigned char * DATA;
DATA = N->data;
return DATA;
return N->data;
}
/**
@ -218,6 +221,9 @@ struct Node * N_Create_From_Link(struct Link * mylink)
mynode->link_ammount = 0;
mynode->link_ammount++;
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));
return mynode;
}

View file

@ -38,5 +38,5 @@ int test_node() {
Free_Link(mylink2);
Free_Link(ResultLink);
Node_Delete(Mynode);
return 0;
return 1;
}