+/**
+ * Destroy a channel and free all resources.
+ *
+ * @param ch Channel to destroy.
+ */
+void
+GMCH_destroy (struct MeshChannel *ch);
+
+/**
+ * Destroy a channel and free all resources.
+ *
+ * @param ch Channel to destroy.
+ */
+void
+GMCH_destroy (struct MeshChannel *ch)
+{
+ struct MeshClient *c;
+
+ if (NULL == ch)
+ return;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying channel %s:%u\n",
+ GMT_2s (ch->t), ch->gid);
+ GMCH_debug (ch);
+
+ c = ch->root;
+ if (NULL != c)
+ {
+ GML_channel_remove (c, ch->lid_root, ch);
+ }
+
+ c = ch->dest;
+ if (NULL != c)
+ {
+ GML_channel_remove (c, ch->lid_dest, ch);
+ }
+
+ channel_rel_free_all (ch->root_rel);
+ channel_rel_free_all (ch->dest_rel);
+
+ GMT_remove_channel (ch->t, ch);
+ GNUNET_STATISTICS_update (stats, "# channels", -1, GNUNET_NO);
+
+ GNUNET_free (ch);
+}
+
+