Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace_mgr] cosmetics and simplifications
[simgrid.git] / src / surf / trace_mgr.cpp
index 834ceb7..4726680 100644 (file)
@@ -312,8 +312,6 @@ tmgr_trace_t tmgr_trace_new_from_string(const char *id, const char *input,
 
 tmgr_trace_t tmgr_trace_new_from_file(const char *filename)
 {
-  char *tstr = NULL;
-  FILE *f = NULL;
   tmgr_trace_t trace = NULL;
 
   if ((!filename) || (strcmp(filename, "") == 0))
@@ -327,12 +325,11 @@ tmgr_trace_t tmgr_trace_new_from_file(const char *filename)
     }
   }
 
-  f = surf_fopen(filename, "r");
-  if (f == NULL)
-    xbt_die("Cannot open file '%s' (path=%s)", filename,
-            xbt_str_join(surf_path, ":"));
+  FILE *f = surf_fopen(filename, "r");
+  xbt_assert(f != NULL,
+      "Cannot open file '%s' (path=%s)", filename, xbt_str_join(surf_path, ":"));
 
-  tstr = xbt_str_from_file(f);
+  char *tstr = xbt_str_from_file(f);
   fclose(f);
   trace = tmgr_trace_new_from_string(filename, tstr, 0.);
   xbt_free(tstr);
@@ -471,11 +468,10 @@ void tmgr_finalize(void)
   xbt_dict_free(&trace_list);
 }
 
-int tmgr_trace_event_free(tmgr_trace_iterator_t trace_event)
+void tmgr_trace_event_unref(tmgr_trace_iterator_t *trace_event)
 {
-  if (trace_event->free_me) {
-    xbt_free(trace_event);
-    return 1;
+  if ((*trace_event)->free_me) {
+    xbt_free(*trace_event);
+    *trace_event = nullptr;
   }
-  return 0;
 }