+/**
+ * \brief Destroys a contidion.
+ *
+ * Destroys and frees the condition's memory.
+ * \param cond A condition
+ */
+void SIMIX_cond_destroy(smx_cond_t cond)
+{
+ DEBUG1("Destroy condition %p", cond);
+ if (cond == NULL)
+ return;
+ else {
+ xbt_fifo_item_t item = NULL;
+ smx_action_t action = NULL;
+
+ xbt_assert0(xbt_swag_size(cond->sleeping) == 0,
+ "Cannot destroy conditional since someone is still using it");
+ xbt_swag_free(cond->sleeping);
+
+ DEBUG1("%d actions registered", xbt_fifo_size(cond->actions));
+ __SIMIX_cond_display_actions(cond);
+ xbt_fifo_foreach(cond->actions, item, action, smx_action_t) {
+ SIMIX_unregister_action_to_condition(action, cond);
+ }
+ __SIMIX_cond_display_actions(cond);
+
+ xbt_fifo_free(cond->actions);
+ xbt_free(cond);
+ return;
+ }
+}