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);
|
portno = multiaddress_get_ip_port(my_multiaddress);
|
||||||
multiaddress_get_ip_address(my_multiaddress, &ip);
|
multiaddress_get_ip_address(my_multiaddress, &ip);
|
||||||
|
|
||||||
|
if (ip == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int sockfd;
|
int sockfd;
|
||||||
struct sockaddr_in serv_addr;
|
struct sockaddr_in serv_addr;
|
||||||
struct hostent *server;
|
struct hostent *server;
|
||||||
|
|
||||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (sockfd < 0) {
|
if (sockfd < 0) {
|
||||||
|
free(ip);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
server = gethostbyname(ip);
|
server = gethostbyname(ip);
|
||||||
|
free(ip);
|
||||||
|
|
||||||
if (server == NULL) {
|
if (server == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -448,6 +448,8 @@ int ipfs_core_http_request_get(struct IpfsNode* local_node, struct HttpRequest*
|
||||||
res = -1;
|
res = -1;
|
||||||
} else {
|
} else {
|
||||||
libp2p_logger_error("http_request", "Results of [%s] returned failure. Return value: %d.\n", url, res);
|
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;
|
return res == CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ int test_routing_put_value() {
|
||||||
struct CliArguments* arguments = NULL;
|
struct CliArguments* arguments = NULL;
|
||||||
|
|
||||||
libp2p_logger_add_class("test_routing");
|
libp2p_logger_add_class("test_routing");
|
||||||
|
libp2p_logger_add_class("api");
|
||||||
// fire up the "publisher"
|
// fire up the "publisher"
|
||||||
if (!drop_and_build_repository(ipfs_path_publisher, 4001, NULL, &peer_id_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");
|
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...
|
// see if we have what we should...
|
||||||
libp2p_logger_debug("test_routing", "About to ask for the server to resolve the publisher.\n");
|
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);
|
arguments = cli_arguments_new(6, args3);
|
||||||
if (!ipfs_name(arguments))
|
if (!ipfs_name(arguments))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -513,6 +515,7 @@ int test_routing_retrieve_file_third_party() {
|
||||||
char multiaddress_string[255] = "";
|
char multiaddress_string[255] = "";
|
||||||
char hash[256] = "";
|
char hash[256] = "";
|
||||||
|
|
||||||
|
/*
|
||||||
libp2p_logger_add_class("online");
|
libp2p_logger_add_class("online");
|
||||||
libp2p_logger_add_class("offline");
|
libp2p_logger_add_class("offline");
|
||||||
libp2p_logger_add_class("multistream");
|
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("test_routing");
|
||||||
libp2p_logger_add_class("api");
|
libp2p_logger_add_class("api");
|
||||||
libp2p_logger_add_class("secio");
|
libp2p_logger_add_class("secio");
|
||||||
|
*/
|
||||||
|
|
||||||
// clean out repository
|
// clean out repository
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue