From e60d0c42e0ccca277117de7ac7b5669abf5e336c Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Fri, 12 Apr 2013 12:51:08 +0000 Subject: - fix memleak complaints from valgrind --- src/testbed/gnunet-service-testbed.c | 8 ++++---- src/testbed/gnunet-service-testbed_links.c | 18 ++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) (limited to 'src/testbed') diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index 7864b0984..9c66634dc 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c @@ -851,15 +851,15 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GST_neighbour_list_clean(); /* Clear peer list */ GST_destroy_peers (); + /* Clear route list */ + GST_route_list_clear (); + /* Clear GST_slave_list */ + GST_slave_list_clear (); /* Clear host list */ for (id = 0; id < GST_host_list_size; id++) if (NULL != GST_host_list[id]) GNUNET_TESTBED_host_destroy (GST_host_list[id]); GNUNET_free_non_null (GST_host_list); - /* Clear route list */ - GST_route_list_clear (); - /* Clear GST_slave_list */ - GST_slave_list_clear (); if (NULL != GST_context) { GNUNET_free_non_null (GST_context->master_ip); diff --git a/src/testbed/gnunet-service-testbed_links.c b/src/testbed/gnunet-service-testbed_links.c index ae984e331..6ed57dd02 100644 --- a/src/testbed/gnunet-service-testbed_links.c +++ b/src/testbed/gnunet-service-testbed_links.c @@ -94,12 +94,6 @@ struct LCFContext */ struct GNUNET_TESTBED_Operation *op; - /** - * The configuration which has to be either used as a template while starting - * the delegated controller or for connecting to the delegated controller - */ - struct GNUNET_CONFIGURATION_Handle *cfg; - /** * The timeout task */ @@ -449,7 +443,10 @@ send_controller_link_response (struct GNUNET_SERVER_Client *client, msg->operation_id = GNUNET_htonll (operation_id); msg->config_size = htons ((uint16_t) config_size); if (NULL != xconfig) + { memcpy (&msg[1], xconfig, xconfig_size); + GNUNET_free (xconfig); + } if (NULL != emsg) memcpy (&msg[1], emsg, strlen (emsg)); GST_queue_message (client, &msg->header); @@ -598,8 +595,6 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) case FINISHED: lcfq = lcfq_head; GNUNET_assert (lcfq->lcf == lcf); - GNUNET_assert (NULL != lcf->cfg); - GNUNET_CONFIGURATION_destroy (lcf->cfg); GNUNET_SERVER_client_drop (lcf->client); GNUNET_TESTBED_operation_done (lcf->op); GNUNET_free (lcf); @@ -783,6 +778,7 @@ neighbour_connect_notify_task (void *cls, } n->reference_cnt++; h->cb (h->cb_cls, n->controller); + GNUNET_free (h); } static void @@ -1014,6 +1010,8 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } + GNUNET_CONFIGURATION_destroy (cfg); + cfg = NULL; op_id = GNUNET_ntohll (msg->operation_id); if (slave_host_id == GST_context->host_id) /* Link from us */ { @@ -1073,7 +1071,6 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_TESTBED_controller_start (GST_context->master_ip, GST_host_list[slave->host_id], &slave_status_callback, slave); - GNUNET_CONFIGURATION_destroy (cfg); new_route = GNUNET_malloc (sizeof (struct Route)); new_route->dest = delegated_host_id; new_route->thru = GST_context->host_id; @@ -1097,7 +1094,6 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_assert (NULL != route); /* because we add routes carefully */ GNUNET_assert (route->dest < GST_slave_list_size); GNUNET_assert (NULL != GST_slave_list[route->dest]); - lcfq->lcf->cfg = cfg; lcfq->lcf->is_subordinate = msg->is_subordinate; lcfq->lcf->state = INIT; lcfq->lcf->operation_id = op_id; @@ -1155,8 +1151,6 @@ GST_free_lcfq () for (lcfq = lcfq_head; NULL != lcfq; lcfq = lcfq_head) { GNUNET_SERVER_client_drop (lcfq->lcf->client); - GNUNET_assert (NULL != lcfq->lcf->cfg); - GNUNET_CONFIGURATION_destroy (lcfq->lcf->cfg); GNUNET_free (lcfq->lcf); GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); GNUNET_free (lcfq); -- cgit v1.2.3