Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a bit of cleaning in chainsend
[simgrid.git] / examples / msg / app-chainsend / broadcaster.c
index f14a1be..f17ed64 100644 (file)
@@ -11,9 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_broadcaster, "Messages specific for the broadca
 xbt_dynar_t build_hostlist_from_hostcount(int hostcount)
 {
   xbt_dynar_t host_list = xbt_dynar_new(sizeof(char*), xbt_free_ref);
-  int i;
-  
-  for (i = 1; i <= hostcount; i++) {
+  for (int i = 1; i <= hostcount; i++) {
     char *hostname = bprintf("host%d", i);
     XBT_DEBUG("%s", hostname);
     xbt_dynar_push(host_list, &hostname);
@@ -24,12 +22,12 @@ xbt_dynar_t build_hostlist_from_hostcount(int hostcount)
 int broadcaster_build_chain(broadcaster_t bc)
 {
   msg_task_t task = NULL;
-  char **cur = (char**)xbt_dynar_iterator_next(bc->it);
-  const char *me = "host0"; /* FIXME: hardcoded*/ /*MSG_host_get_name(MSG_host_self());*/
-  const char *current_host = NULL;
-  const char *prev = NULL;
-  const char *next = NULL;
-  const char *last = NULL;
+  char** cur               = (char**)xbt_dynar_iterator_next(bc->it);
+  const char* me           = MSG_host_get_name(MSG_host_self());
+  const charcurrent_host = NULL;
+  const char* prev         = NULL;
+  const char* next         = NULL;
+  const char* last         = NULL;
 
   /* Build the chain if there's at least one peer */
   if (cur != NULL) {
@@ -62,8 +60,7 @@ int broadcaster_build_chain(broadcaster_t bc)
 
 int broadcaster_send_file(broadcaster_t bc)
 {
-  const char *me = "host0"; /* FIXME: hardcoded*/ /*MSG_host_get_name(MSG_host_self());*/
-  //msg_comm_t comm = NULL;
+  const char* me  = MSG_host_get_name(MSG_host_self());
   msg_task_t task = NULL;
 
   bc->current_piece = 0;
@@ -101,7 +98,7 @@ static void broadcaster_destroy(broadcaster_t bc)
   /* Destroy iterator and hostlist */
   xbt_dynar_iterator_delete(bc->it);
   xbt_dynar_free(&bc->pending_sends);
-  xbt_dynar_free(&bc->host_list); /* FIXME: host names are not free'd */
+  xbt_dynar_free(&bc->host_list);
   xbt_free(bc);
 }