diff --git a/include/ipfs/node/node.h b/include/ipfs/node/node.h index 5bd4578..d064d10 100644 --- a/include/ipfs/node/node.h +++ b/include/ipfs/node/node.h @@ -28,7 +28,7 @@ struct Node unsigned char * encoded; struct Cid * cached; int link_ammount; - struct Link * links[]; + struct Link* links[]; }; /*==================================================================================== @@ -118,7 +118,7 @@ int Node_Remove_Link(char * Name, struct Node * mynode); * @param linksz: sizeof(your cid here) * Returns your node with the newly added link */ -struct Node * N_Add_Link(struct Node ** mynode, struct Link * mylink, size_t linksz); +struct Node* N_Add_Link(struct Node** mynode, struct Link* mylink, size_t linksz); /*N_Create_From_Link * Create a node from a link diff --git a/node/node.c b/node/node.c index 43fcfac..3a84e9d 100644 --- a/node/node.c +++ b/node/node.c @@ -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* Node_Get_Data(struct Node* N) { - unsigned char * DATA; - DATA = N->data; - return DATA; + return N->data; } /** @@ -93,7 +96,7 @@ int Node_Set_Cid(struct Node* N, struct Cid* cid) { * @param Node: The node you want to copy (struct CP_Node *) * Returns a copy of the node you wanted to copy. */ -struct Node * Node_Copy(struct Node * CP_Node) +struct Node* Node_Copy(struct Node * CP_Node) { struct Node * CN; CN = (struct Node*) malloc(sizeof(struct Node) + sizeof(struct Link) * 2); @@ -133,7 +136,7 @@ void Node_Delete(struct Node * N) * @param Name: (char * name) searches for link with this name * Returns the link struct if it's found otherwise returns NULL */ -struct Link * Node_Get_Link(struct Node * N, char * Name) +struct Link* Node_Get_Link(struct Node * N, char * Name) { struct Link * L; for(int i=0;ilink_ammount;i++) @@ -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; } diff --git a/test/node/test_node.h b/test/node/test_node.h index a61c851..bdf89e9 100644 --- a/test/node/test_node.h +++ b/test/node/test_node.h @@ -38,5 +38,5 @@ int test_node() { Free_Link(mylink2); Free_Link(ResultLink); Node_Delete(Mynode); - return 0; + return 1; }