Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
free dicts
[simgrid.git] / teshsuite / msg / storage / storage.c
index e15baad..a9d1ebc 100644 (file)
@@ -30,17 +30,18 @@ void storage_info(msg_host_t host)
 
   xbt_dict_foreach(storage_list,cursor,mount_name,storage_name)
   {
-       XBT_INFO("Storage name: %s, mount name: %s", storage_name, mount_name);
+    XBT_INFO("Storage name: %s, mount name: %s", storage_name, mount_name);
 
     sg_storage_size_t free_size = MSG_storage_get_free_size(mount_name);
     sg_storage_size_t used_size = MSG_storage_get_used_size(mount_name);
 
-    XBT_INFO("Free size: %zu bytes", free_size);
-    XBT_INFO("Used size: %zu bytes", used_size);
+    XBT_INFO("Free size: %" PRIu64 " bytes", free_size);
+    XBT_INFO("Used size: %" PRIu64 " bytes", used_size);
 
     storage = MSG_storage_get_by_name(storage_name);
     display_storage_properties(storage);
   }
+  xbt_dict_free(&storage_list);
 }
 
 void display_storage_properties(msg_storage_t storage){
@@ -63,7 +64,7 @@ int hsm_put(const char *remote_host, const char *src, const char *dest){
   sg_storage_size_t read_size = read_local_file(src);
 
   // Send file
-  XBT_INFO("%s sends %zu to %s",MSG_host_get_name(MSG_host_self()),read_size,remote_host);
+  XBT_INFO("%s sends %" PRIu64 " to %s",MSG_host_get_name(MSG_host_self()),read_size,remote_host);
   msg_task_t to_execute = MSG_task_create((const char*)"hsm_put", 0, (double) read_size, (void*)dest);
   MSG_task_send(to_execute, remote_host);
 
@@ -86,7 +87,7 @@ sg_storage_size_t read_local_file(const char *src)
   file_size = MSG_file_get_size(file);
 
   read = MSG_file_read(file, file_size);
-  XBT_INFO("%s has read %zu on %s",MSG_host_get_name(MSG_host_self()),read,src);
+  XBT_INFO("%s has read %" PRIu64 " on %s",MSG_host_get_name(MSG_host_self()),read,src);
   MSG_file_close(file);
 
   return read;
@@ -107,6 +108,7 @@ void display_storage_info(msg_host_t host)
   {
     dump_storage_by_name(storage_name);
   }
+  xbt_dict_free(&storage_list);
 }
 
 void dump_storage_by_name(char *name){
@@ -125,24 +127,26 @@ void display_storage_content(msg_storage_t storage){
   XBT_INFO("Print the content of the storage element: %s",MSG_storage_get_name(storage));
   xbt_dict_cursor_t cursor = NULL;
   char *file;
-  sg_storage_size_t size;
+  sg_storage_size_t *psize;
   xbt_dict_t content = MSG_storage_get_content(storage);
   if (content){
-    xbt_dict_foreach(content, cursor, file, size)
-    XBT_INFO("%s size: %" PRIu64 "bytes", file, size);
+    xbt_dict_foreach(content, cursor, file, psize)
+    XBT_INFO("%s size: %" PRIu64 " bytes", file, *psize);
   } else {
     XBT_INFO("No content.");
   }
+  xbt_dict_free(&content);
 }
 
 void get_set_storage_data(const char *storage_name){
-       XBT_INFO("*** GET/SET DATA for storage element: %s ***",storage_name);
-       msg_storage_t storage = MSG_storage_get_by_name(storage_name);
-       char *data = MSG_storage_get_data(storage);
-       XBT_INFO("Get data: '%s'", data);
-       MSG_storage_set_data(storage,strdup("Some data"));
-       data = MSG_storage_get_data(storage);
-       XBT_INFO("Set and get data: '%s'", data);
+  XBT_INFO("*** GET/SET DATA for storage element: %s ***",storage_name);
+  msg_storage_t storage = MSG_storage_get_by_name(storage_name);
+  char *data = MSG_storage_get_data(storage);
+  XBT_INFO("Get data: '%s'", data);
+
+  MSG_storage_set_data(storage,strdup("Some data"));
+  data = MSG_storage_get_data(storage);
+  XBT_INFO("Set and get data: '%s'", data);
 }
 
 int client(int argc, char *argv[])