Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] free the type values
[simgrid.git] / src / simix / smx_network.c
index 113b9d6..0fe6778 100644 (file)
@@ -22,7 +22,7 @@ static smx_action_t SIMIX_comm_new(e_smx_comm_type_t type);
 static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_action_t comm);
 static XBT_INLINE void SIMIX_rdv_remove(smx_rdv_t rdv, smx_action_t comm);
 static smx_action_t SIMIX_rdv_get_request(smx_rdv_t rdv, e_smx_comm_type_t type,
-                                                                                 int (*match_fun)(void *, void *), void *);
+                                         int (*match_fun)(void *, void *), void *);
 static void SIMIX_rdv_free(void *data);
 
 void SIMIX_network_init(void)
@@ -164,10 +164,9 @@ smx_action_t SIMIX_comm_new(e_smx_comm_type_t type)
   smx_action_t act;
 
   /* alloc structures */
-  act = xbt_new0(s_smx_action_t, 1);
+  act = xbt_mallocator_get(simix_global->action_mallocator);
   act->type = SIMIX_ACTION_COMMUNICATE;
   act->state = SIMIX_WAITING;
-  act->request_list = xbt_fifo_new();
 
   /* set communication */
   act->comm.type = type;
@@ -212,11 +211,7 @@ void SIMIX_comm_destroy(smx_action_t action)
   TRACE_smx_action_destroy(action);
 #endif
 
-  if (action->name)
-    xbt_free(action->name);
-
-  xbt_fifo_free(action->request_list);
-
+  xbt_free(action->name);
   SIMIX_comm_destroy_internal_actions(action);
 
   if (action->comm.detached && action->state != SIMIX_DONE) {
@@ -225,7 +220,7 @@ void SIMIX_comm_destroy(smx_action_t action)
     ((void_f_pvoid_t) action->comm.src_data)(action->comm.src_buff);
   }
 
-  xbt_free(action);
+  xbt_mallocator_release(simix_global->action_mallocator, action);
 }
 
 void SIMIX_comm_destroy_internal_actions(smx_action_t action)
@@ -271,7 +266,7 @@ smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
 
   /* If the communication action is detached then decrease the refcount
    * by one, so it will be eliminated by the receivers destroy call */
-  if(detached){
+  if (detached) {
     action->comm.detached = 1;
     action->comm.refcount--;
   }
@@ -508,6 +503,7 @@ static XBT_INLINE void SIMIX_comm_start(smx_action_t action)
 
 void SIMIX_comm_finish(smx_action_t action)
 {
+  unsigned int destroy_count = 0;
   smx_req_t req;
 
   while ((req = xbt_fifo_shift(action->request_list))) {
@@ -606,7 +602,11 @@ void SIMIX_comm_finish(smx_action_t action)
 
     req->issuer->waiting_action = NULL;
     SIMIX_request_answer(req);
+    destroy_count++;
   }
+
+  while(destroy_count-- > 0)
+    SIMIX_comm_destroy(action);
 }
 
 void SIMIX_post_comm(smx_action_t action)
@@ -721,33 +721,6 @@ void* SIMIX_comm_get_dst_data(smx_action_t action)
   return action->comm.dst_data;
 }
 
-void* SIMIX_comm_get_src_buff(smx_action_t action)
-{
-  return action->comm.src_buff;
-}
-
-void* SIMIX_comm_get_dst_buff(smx_action_t action)
-{
-  return action->comm.dst_buff;
-}
-
-size_t SIMIX_comm_get_src_buff_size(smx_action_t action)
-{
-  return action->comm.src_buff_size;
-}
-
-size_t SIMIX_comm_get_dst_buff_size(smx_action_t action)
-{
-  size_t buff_size;
-
-  if (action->comm.dst_buff_size)
-    buff_size = *(action->comm.dst_buff_size);
-  else
-    buff_size = 0;
-
-  return buff_size;
-}
-
 smx_process_t SIMIX_comm_get_src_proc(smx_action_t action)
 {
   return action->comm.src_proc;