Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Missing prototypes
[simgrid.git] / src / surf / trace_mgr.c
index 1dc603d..b5ddf85 100644 (file)
@@ -6,7 +6,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/sysdep.h"
-#include "xbt/error.h"
+#include "xbt/log.h"
 #include "xbt/dict.h"
 #include "trace_mgr_private.h"
 #include "surf_private.h"
@@ -49,7 +49,7 @@ tmgr_trace_t tmgr_trace_new(const char *filename)
   tmgr_event_t last_event = NULL;
 
   if (trace_list) {
-    xbt_dict_get(trace_list, filename, (void **) &trace);
+    trace = xbt_dict_get_or_null(trace_list, filename);
     if (trace)
       return trace;
   }
@@ -109,6 +109,22 @@ tmgr_trace_t tmgr_trace_new(const char *filename)
   return trace;
 }
 
+tmgr_trace_t tmgr_empty_trace_new(void)
+{
+  tmgr_trace_t trace = NULL;
+  /*double periodicity = -1.0;  No periodicity by default; unused variables
+  tmgr_event_t last_event = NULL;*/
+  s_tmgr_event_t event;
+
+  trace = xbt_new0(s_tmgr_trace_t, 1);
+  trace->event_list = xbt_dynar_new(sizeof(s_tmgr_event_t), NULL);
+
+  event.delta = 0.0;
+  event.value = 0.0;
+  xbt_dynar_push(trace->event_list, &event);
+
+  return trace;
+}
 
 void tmgr_trace_free(tmgr_trace_t trace)
 {
@@ -125,7 +141,6 @@ tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t h,
 {
   tmgr_trace_event_t trace_event = NULL;
 
-
   trace_event = xbt_new0(s_tmgr_trace_event_t, 1);
   trace_event->trace = trace;
   trace_event->idx = offset;
@@ -152,7 +167,7 @@ tmgr_trace_event_t tmgr_history_get_next_event_leq(tmgr_history_t h,
                                                   double *value,
                                                   void **resource)
 {
-  double event_date = xbt_heap_maxkey(h->heap);
+  double event_date = tmgr_history_next_date(h);
   tmgr_trace_event_t trace_event = NULL;
   tmgr_event_t event = NULL;
   tmgr_trace_t trace = NULL;
@@ -166,7 +181,6 @@ tmgr_trace_event_t tmgr_history_get_next_event_leq(tmgr_history_t h,
   trace = trace_event->trace;
   event = xbt_dynar_get_ptr(trace->event_list, trace_event->idx);
 
-
   *value = event->value;
   *resource = trace_event->resource;