X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9b757886241c3fc8c055842b3cf7fef7494031d7..9f4ddf3b15fccdab0f2666bf44061e7fd8305f49:/src/surf/trace_mgr.c diff --git a/src/surf/trace_mgr.c b/src/surf/trace_mgr.c index 7cc122601d..c49bd7ca67 100644 --- a/src/surf/trace_mgr.c +++ b/src/surf/trace_mgr.c @@ -1,6 +1,5 @@ -/* $Id$ */ - -/* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */ +/* Copyright (c) 2004, 2005, 2007, 2009, 2010. The SimGrid Team. + * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -47,12 +46,12 @@ tmgr_trace_t tmgr_trace_new_from_string(const char *id, const char *input, if (trace_list) { trace = xbt_dict_get_or_null(trace_list, id); if (trace) { - WARN1("Ignoring redefinition of trace %s", id); + XBT_WARN("Ignoring redefinition of trace %s", id); return trace; } } - xbt_assert1(periodicity >= 0, + xbt_assert(periodicity >= 0, "Invalid periodicity %lg (must be positive)", periodicity); trace = xbt_new0(s_tmgr_trace_t, 1); @@ -70,30 +69,28 @@ tmgr_trace_t tmgr_trace_new_from_string(const char *id, const char *input, continue; if (sscanf(val, "%lg" " " "%lg" "\n", &event.delta, &event.value) != 2) - xbt_die(bprintf - ("%s:%d: Syntax error in trace\n%s", id, linecount, input)); + xbt_die("%s:%d: Syntax error in trace\n%s", id, linecount, input); if (last_event) { if (last_event->delta > event.delta) { - xbt_die(bprintf - ("%s:%d: Invalid trace: Events must be sorted, but time %lg > time %lg.\n%s", - id, linecount, last_event->delta, event.delta, input)); + xbt_die("%s:%d: Invalid trace: Events must be sorted, " + "but time %lg > time %lg.\n%s", + id, linecount, last_event->delta, event.delta, input); } last_event->delta = event.delta - last_event->delta; } xbt_dynar_push(trace->event_list, &event); last_event = - xbt_dynar_get_ptr(trace->event_list, - xbt_dynar_length(trace->event_list) - 1); + xbt_dynar_get_ptr(trace->event_list, + xbt_dynar_length(trace->event_list) - 1); } if (last_event) last_event->delta = periodicity; if (!trace_list) - trace_list = xbt_dict_new(); + trace_list = xbt_dict_new_homogeneous((void (*)(void *)) tmgr_trace_free); - xbt_dict_set(trace_list, id, (void *) trace, - (void (*)(void *)) tmgr_trace_free); + xbt_dict_set(trace_list, id, (void *) trace, NULL); xbt_dynar_free(&list); return trace; @@ -101,6 +98,7 @@ tmgr_trace_t tmgr_trace_new_from_string(const char *id, const char *input, tmgr_trace_t tmgr_trace_new(const char *filename) { + char *tstr = NULL; FILE *f = NULL; tmgr_trace_t trace = NULL; @@ -110,16 +108,16 @@ tmgr_trace_t tmgr_trace_new(const char *filename) if (trace_list) { trace = xbt_dict_get_or_null(trace_list, filename); if (trace) { - WARN1("Ignoring redefinition of trace %s", filename); + XBT_WARN("Ignoring redefinition of trace %s", filename); return trace; } } f = surf_fopen(filename, "r"); - xbt_assert2(f!=NULL, "Cannot open file '%s' (path=%s)", filename, - xbt_str_join(surf_path,":")); + xbt_assert(f != NULL, "Cannot open file '%s' (path=%s)", filename, + xbt_str_join(surf_path, ":")); - char *tstr = xbt_str_from_file(f); + tstr = xbt_str_from_file(f); fclose(f); trace = tmgr_trace_new_from_string(filename, tstr, 0.); xbt_free(tstr); @@ -162,7 +160,7 @@ tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t h, trace_event->idx = offset; trace_event->model = model; - xbt_assert0((trace_event->idx < xbt_dynar_length(trace->event_list)), + xbt_assert((trace_event->idx < xbt_dynar_length(trace->event_list)), "You're referring to an event that does not exist!"); xbt_heap_push(h->heap, trace_event, start_time);