}
+/**
+ * Recursively destory the path tree of a tunnel.
+ * Note: it does not liberate memory for itself, parent must do it!
+ *
+ * @param n The node to destroy, along with children.
+ *
+ * @return GNUNET_OK on success
+ */
+static void
+tunnel_destroy_tree_node (struct MeshTunnelPathNode *n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n->nchildren; i++)
+ {
+ tunnel_destroy_tree_node(&n->children[i]);
+ }
+ GNUNET_free (n->children);
+}
+
+
/**
* Destroy the tunnel and free any allocated resources linked to it
*
q = qn;
/* TODO cancel core transmit ready in case it was active */
}
+
+ GNUNET_CONTAINER_multihashmap_destroy(t->paths->first_hops);
+ tunnel_destroy_tree_node(t->paths->root);
+ GNUNET_free(t->paths->root);
+ GNUNET_free (t->paths);
GNUNET_free (t);
return r;
}
{
int r;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: D %p\n", value);
r = tunnel_destroy ((struct MeshTunnel *) value);
return r;
}
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
+ t->paths = GNUNET_malloc (sizeof(struct MeshTunnelPath));
+ t->paths->first_hops = GNUNET_CONTAINER_multihashmap_create(32);
+ t->paths->t = t;
+ t->paths->root = GNUNET_malloc(sizeof(struct MeshTunnelPathNode));
+ t->paths->root->status = MESH_PEER_READY;
+ t->paths->root->t = t;
+ t->paths->root->peer = peer_info_get(&my_full_id);
+ t->paths->me = t->paths->root;
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;