From 3f3cc4d7736dd7130e539d8e103d23095e5a214a Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Tue, 25 Jun 2013 11:08:10 +0000 Subject: - fix memleak --- src/mesh/gnunet-service-mesh-new.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c index ef04ea259..838c967fc 100644 --- a/src/mesh/gnunet-service-mesh-new.c +++ b/src/mesh/gnunet-service-mesh-new.c @@ -754,6 +754,16 @@ tunnel_notify_connection_broken (struct MeshTunnel *t, GNUNET_PEER_Id p1, static void tunnel_use_path (struct MeshTunnel *t, struct MeshPeerPath *p); +/** + * Tunnel is empty: destroy it. + * + * Notifies all participants (peers, cleints) about the destruction. + * + * @param t Tunnel to destroy. + */ +static void +tunnel_destroy_empty (struct MeshTunnel *t); + /** * @brief Queue and pass message to core when possible. * @@ -1285,6 +1295,7 @@ peer_info_destroy (struct MeshPeerInfo *pi) struct GNUNET_PeerIdentity id; struct MeshPeerPath *p; struct MeshPeerPath *nextp; + unsigned int i; GNUNET_PEER_resolve (pi->id, &id); GNUNET_PEER_change_rc (pi->id, -1); @@ -1308,6 +1319,9 @@ peer_info_destroy (struct MeshPeerInfo *pi) path_destroy (p); p = nextp; } + for (i = 0; i < pi->ntunnels; i++) + tunnel_destroy_empty (pi->tunnels[i]); + GNUNET_array_grow (pi->tunnels, pi->ntunnels, 0); GNUNET_free (pi); return GNUNET_OK; } -- cgit v1.2.3