Minor memory leak fixes
This commit is contained in:
parent
87cc96a011
commit
7aa81936ec
3 changed files with 13 additions and 2 deletions
|
@ -28,16 +28,21 @@ int api_running(struct IpfsNode* local_node) {
|
|||
portno = multiaddress_get_ip_port(my_multiaddress);
|
||||
multiaddress_get_ip_address(my_multiaddress, &ip);
|
||||
|
||||
if (ip == NULL)
|
||||
return 0;
|
||||
|
||||
int sockfd;
|
||||
struct sockaddr_in serv_addr;
|
||||
struct hostent *server;
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd < 0) {
|
||||
free(ip);
|
||||
return 0;
|
||||
}
|
||||
|
||||
server = gethostbyname(ip);
|
||||
free(ip);
|
||||
|
||||
if (server == NULL) {
|
||||
return 0;
|
||||
|
|
|
@ -448,6 +448,8 @@ int ipfs_core_http_request_get(struct IpfsNode* local_node, struct HttpRequest*
|
|||
res = -1;
|
||||
} else {
|
||||
libp2p_logger_error("http_request", "Results of [%s] returned failure. Return value: %d.\n", url, res);
|
||||
if (s.ptr != NULL)
|
||||
free(s.ptr);
|
||||
}
|
||||
return res == CURLE_OK;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ int test_routing_put_value() {
|
|||
struct CliArguments* arguments = NULL;
|
||||
|
||||
libp2p_logger_add_class("test_routing");
|
||||
|
||||
libp2p_logger_add_class("api");
|
||||
// fire up the "publisher"
|
||||
if (!drop_and_build_repository(ipfs_path_publisher, 4001, NULL, &peer_id_publisher)) {
|
||||
libp2p_logger_error("test_routing", "Unable to drop and build repository.\n");
|
||||
|
@ -65,7 +65,9 @@ int test_routing_put_value() {
|
|||
|
||||
// see if we have what we should...
|
||||
libp2p_logger_debug("test_routing", "About to ask for the server to resolve the publisher.\n");
|
||||
char* args3[] = {"ipfs", "--config", ipfs_path_publisher, "name", "resolve", peer_id_publisher};
|
||||
char ipns[126];
|
||||
sprintf(ipns, "/ipns/%s", peer_id_publisher);
|
||||
char* args3[] = {"ipfs", "--config", ipfs_path_publisher, "name", "resolve", ipns};
|
||||
arguments = cli_arguments_new(6, args3);
|
||||
if (!ipfs_name(arguments))
|
||||
goto exit;
|
||||
|
@ -513,6 +515,7 @@ int test_routing_retrieve_file_third_party() {
|
|||
char multiaddress_string[255] = "";
|
||||
char hash[256] = "";
|
||||
|
||||
/*
|
||||
libp2p_logger_add_class("online");
|
||||
libp2p_logger_add_class("offline");
|
||||
libp2p_logger_add_class("multistream");
|
||||
|
@ -525,6 +528,7 @@ int test_routing_retrieve_file_third_party() {
|
|||
libp2p_logger_add_class("test_routing");
|
||||
libp2p_logger_add_class("api");
|
||||
libp2p_logger_add_class("secio");
|
||||
*/
|
||||
|
||||
// clean out repository
|
||||
|
||||
|
|
Loading…
Reference in a new issue