Fixed minor leak in test and more compiler warnings
This commit is contained in:
parent
bf0cbfb412
commit
88d177cf4a
3 changed files with 16 additions and 0 deletions
|
@ -27,10 +27,16 @@ int ipfs_cid_protobuf_encode(struct Cid* cid, unsigned char* buffer, size_t buff
|
|||
int retVal = 0;
|
||||
if (cid != NULL) {
|
||||
retVal = protobuf_encode_varint(1, ipfs_cid_message_fields[0], cid->version, buffer, buffer_length, &bytes_used);
|
||||
if (retVal == 0)
|
||||
return 0;
|
||||
*bytes_written += bytes_used;
|
||||
retVal = protobuf_encode_varint(2, ipfs_cid_message_fields[1], cid->codec, &buffer[*bytes_written], buffer_length - (*bytes_written), &bytes_used);
|
||||
if (retVal == 0)
|
||||
return 0;
|
||||
*bytes_written += bytes_used;
|
||||
retVal = protobuf_encode_length_delimited(3, ipfs_cid_message_fields[2], (char*)cid->hash, cid->hash_length, &buffer[*bytes_written], buffer_length - (*bytes_written), &bytes_used);
|
||||
if (retVal == 0)
|
||||
return 0;
|
||||
*bytes_written += bytes_used;
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -75,12 +75,18 @@ int ipfs_node_link_protobuf_encode(struct NodeLink* link, unsigned char* buffer,
|
|||
int retVal = 0;
|
||||
*bytes_written = 0;
|
||||
retVal = protobuf_encode_length_delimited(1, ipfs_node_link_message_fields[0], link->name, strlen(link->name), &buffer[*bytes_written], max_buffer_length - *bytes_written, &bytes_used);
|
||||
if (retVal == 0)
|
||||
return 0;
|
||||
*bytes_written += bytes_used;
|
||||
// cid
|
||||
size_t cid_size = ipfs_cid_protobuf_encode_size(link->cid);
|
||||
unsigned char cid_buffer[cid_size];
|
||||
retVal = ipfs_cid_protobuf_encode(link->cid, cid_buffer, cid_size, &bytes_used);
|
||||
if (retVal == 0)
|
||||
return 0;
|
||||
retVal = protobuf_encode_length_delimited(2, ipfs_node_link_message_fields[1], (char*)&cid_buffer[0], bytes_used, &buffer[*bytes_written], max_buffer_length - *bytes_written, &bytes_used);
|
||||
if (retVal == 0)
|
||||
return 0;
|
||||
*bytes_written += bytes_used;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ int test_node() {
|
|||
unsigned char * ahash = (unsigned char*)"QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG";
|
||||
struct NodeLink * mylink;
|
||||
int retVal = ipfs_node_link_new(name,ahash, &mylink);
|
||||
if (retVal == 0)
|
||||
return 0;
|
||||
|
||||
//Link Two for testing purposes
|
||||
char * name2 = "Simo";
|
||||
|
@ -83,6 +85,8 @@ l_exit:
|
|||
ipfs_node_link_free(control);
|
||||
if (results != NULL)
|
||||
ipfs_node_link_free(results);
|
||||
if (buffer != NULL)
|
||||
free(buffer);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue