Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] encapsulating the open/close of the trace file
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 6 Dec 2010 00:55:48 +0000 (00:55 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 6 Dec 2010 00:55:48 +0000 (00:55 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8985 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/instr/instr_interface.c
src/instr/instr_paje.c
src/instr/instr_private.h

index 1c5f19e..5f137ac 100644 (file)
@@ -25,19 +25,7 @@ int TRACE_start()
   }
 
   /* open the trace file */
   }
 
   /* open the trace file */
-  char *filename = TRACE_get_filename();
-  if (!filename) {
-    THROW0(tracing_error, TRACE_ERROR_START,
-           "Trace filename is not initialized.");
-    return 0;
-  }
-  FILE *file = fopen(filename, "w");
-  if (!file) {
-    THROW1(tracing_error, TRACE_ERROR_START,
-           "Tracefile %s could not be opened for writing.", filename);
-  } else {
-    TRACE_paje_start(file);
-  }
+  TRACE_paje_start();
 
   /* activate trace */
   TRACE_activate ();
 
   /* activate trace */
   TRACE_activate ();
@@ -113,9 +101,11 @@ int TRACE_end()
 {
   if (!TRACE_is_active())
     return 1;
 {
   if (!TRACE_is_active())
     return 1;
-  FILE *file = TRACE_paje_end();
-  fclose(file);
 
 
+  /* close the trace file */
+  TRACE_paje_end();
+
+  /* activate trace */
   TRACE_desactivate ();
   return 0;
 }
   TRACE_desactivate ();
   return 0;
 }
index 098440e..ad83fd1 100644 (file)
@@ -41,17 +41,21 @@ static int pajeNewEventId = 27;
 
 #define TRACE_LINE_SIZE 1000
 
 
 #define TRACE_LINE_SIZE 1000
 
-void TRACE_paje_start(FILE * file)
+void TRACE_paje_start(void)
 {
 {
-  tracing_file = file;
+  char *filename = TRACE_get_filename();
+  tracing_file = fopen(filename, "w");
+  if (!tracing_file) {
+    THROW1(tracing_error, TRACE_ERROR_FILE_OPEN,
+           "Tracefile %s could not be opened for writing.", filename);
+  }
 }
 
 }
 
-FILE *TRACE_paje_end(void)
+void TRACE_paje_end(void)
 {
 {
-  return tracing_file;
+  fclose(tracing_file);
 }
 
 }
 
-
 void TRACE_paje_create_header(void)
 {
   if (!TRACE_is_active())
 void TRACE_paje_create_header(void)
 {
   if (!TRACE_is_active())
index 494de70..f54a788 100644 (file)
@@ -20,8 +20,8 @@
 
 /* from paje.c */
 void TRACE_paje_create_header(void);
 
 /* from paje.c */
 void TRACE_paje_create_header(void);
-void TRACE_paje_start(FILE * file);
-FILE *TRACE_paje_end(void);
+void TRACE_paje_start(void);
+void TRACE_paje_end(void);
 void pajeDefineContainerType(const char *alias, const char *containerType,
                              const char *name);
 void pajeDefineStateType(const char *alias, const char *containerType,
 void pajeDefineContainerType(const char *alias, const char *containerType,
                              const char *name);
 void pajeDefineStateType(const char *alias, const char *containerType,