Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Check that table[0].name is defined.
[simgrid.git] / src / surf / surf_interface.cpp
index 0f393e8..6be998b 100644 (file)
@@ -334,7 +334,9 @@ int find_model_description(s_surf_model_description_t * table,
     if (!strcmp(name, table[i].name)) {
       return i;
     }
-  name_list = strdup(table[0].name);
+  if (!table[0].name)
+    xbt_die("No model is valid! This is a bug.");
+  name_list = xbt_strdup(table[0].name);
   for (i = 1; table[i].name; i++) {
     name_list = (char *) xbt_realloc(name_list, strlen(name_list) + strlen(table[i].name) + 3);
     strcat(name_list, ", ");
@@ -370,6 +372,11 @@ static XBT_INLINE void surf_workstation_free(void *r)
   delete static_cast<WorkstationPtr>(r);
 }
 
+static XBT_INLINE void surf_storage_free(void *r)
+{
+  delete static_cast<StoragePtr>(r);
+}
+
 
 void sg_version(int *ver_major,int *ver_minor,int *ver_patch) {
   *ver_major = SIMGRID_VERSION_MAJOR;
@@ -397,6 +404,7 @@ void surf_init(int *argc, char **argv)
   SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_cpu_free);
   SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_workstation_free);
   SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_link_free);
+  SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
 
   xbt_init(argc, argv);
   if (!model_list)
@@ -437,7 +445,7 @@ void surf_exit(void)
   xbt_lib_free(&as_router_lib);
   xbt_lib_free(&storage_lib);
   xbt_lib_free(&storage_type_lib);
-
+  xbt_lib_free(&file_lib);
   xbt_dict_free(&watched_hosts_lib);
 
   xbt_dynar_foreach(model_list, iter, model)