- if (context) {
-/* m_process_t self = msg_global->current_process; */
- if(context->save==NULL) {
- /* WARNING("**** Yielding to somebody else ****"); */
- /* WARNING("Saving current_context value (%p) to context(%p)->save",current_context,context); */
- context->save = current_context ;
- context->uc.uc_link = &(current_context->uc);
- /* WARNING("current_context becomes context(%p) ",context); */
- current_context = context ;
- /* WARNING("Current position memorized (context->save). Jumping to context (%p)",context); */
- if(!swapcontext (&(context->save->uc), &(context->uc)))
- xbt_assert0(0,"Context swapping failure");
- /* WARNING("I am (%p). Coming back\n",context); */
- } else {
- xbt_context_t old_context = context->save ;
- /* WARNING("**** Back ! ****"); */
- /* WARNING("Setting current_context (%p) to context(%p)->save",current_context,context); */
- current_context = context->save ;
- /* WARNING("Setting context(%p)->save to NULL",current_context,context); */
- context->save = NULL ;
- /* WARNING("Current position memorized (%p). Jumping to context (%p)",context,old_context); */
- if(!swapcontext (&(context->uc), &(old_context->uc)) )
- xbt_assert0(0,"Context swapping failure");
- /* WARNING("I am (%p). Coming back\n",context); */
- }
-/* msg_global->current_process = self; */
- }
+ while((context=xbt_swag_extract(context_living)))
+ xbt_context_free(context);
+
+ xbt_swag_free(context_living);
+
+ init_context = current_context = NULL ;
+}
+
+/**
+ * \param context poor victim
+ *
+ * This function simply kills \a context... scarry isn't it ?
+ */
+void xbt_context_free(xbt_context_t context)
+{
+ int i ;
+
+ xbt_swag_remove(context, context_living);
+ for(i=0;i<context->argc; i++)
+ if(context->argv[i]) xbt_free(context->argv[i]);
+ if(context->argv) xbt_free(context->argv);
+
+ if(context->cleanup_func)
+ context->cleanup_func(context->cleanup_arg);
+ xbt_context_destroy(context);