Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #190 from Takishipp/clean_events
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 19 Jun 2017 12:20:00 +0000 (14:20 +0200)
committerGitHub <noreply@github.com>
Mon, 19 Jun 2017 12:20:00 +0000 (14:20 +0200)
fix leak of memory caused by DefineEventTypeEvent call

1  2 
src/instr/instr_paje_trace.cpp

@@@ -217,16 -217,18 +217,16 @@@ void DefineContainerEvent(type_t type
    XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineContainerType);
    //print it
    if (instr_fmt_type == instr_fmt_paje) {
 -              XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineContainerType, TRACE_precision(), 0.);
 -              stream << std::fixed << std::setprecision(TRACE_precision());
 -              stream << PAJE_DefineContainerType;
 -              stream << " " << type->id
 -                              << " " << type->father->id
 -                              << " " << type->name;
 -              print_row();
 -      } else if (instr_fmt_type == instr_fmt_TI) {
 -              /* Nothing to do */
 -      } else {
 -              THROW_IMPOSSIBLE;
 -      }
 +    XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineContainerType, TRACE_precision(), 0.);
 +    stream << std::fixed << std::setprecision(TRACE_precision());
 +    stream << PAJE_DefineContainerType;
 +    stream << " " << type->id << " " << type->father->id << " " << type->name;
 +    print_row();
 +  } else if (instr_fmt_type == instr_fmt_TI) {
 +    /* Nothing to do */
 +  } else {
 +    THROW_IMPOSSIBLE;
 +  }
    //--
  }
  
@@@ -271,24 -273,13 +271,13 @@@ if (instr_fmt_type == instr_fmt_paje) 
  }
  
  
DefineEventTypeEvent::DefineEventTypeEvent(type_t type)
void LogDefineEventType(type_t type)
  {
-   this->event_type                        = PAJE_DefineEventType;
-   this->timestamp                         = 0;
-   this->type = type;
-   XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
    //print it
-   print();
- }
- void DefineEventTypeEvent::print() {
    if (instr_fmt_type == instr_fmt_paje) {
-     XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+     XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineEventType, TRACE_precision(), 0.);
      stream << std::fixed << std::setprecision(TRACE_precision());
-     stream << (int)this->event_type;
+     stream << PAJE_DefineEventType;
      stream << " " << type->id << " " << type->father->id << " " << type->name;
      print_row();
    } else if (instr_fmt_type == instr_fmt_TI) {
@@@ -345,12 -336,12 +334,12 @@@ if (instr_fmt_type == instr_fmt_paje) 
      stream << PAJE_CreateContainer;
      stream << " ";
    /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
 -     if (timestamp < 1e-12)
 -         stream << 0;
 -      else 
 -         stream << timestamp;
 -         stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \""
 -            << container->name << "\"";
 +    if (timestamp < 1e-12)
 +      stream << 0;
 +    else
 +      stream << timestamp;
 +    stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \""
 +           << container->name << "\"";
  
      print_row();
    } else if (instr_fmt_type == instr_fmt_TI) {
@@@ -765,7 -756,7 +754,7 @@@ ResetStateEvent::ResetStateEvent (doubl
    XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
  
    insert_into_buffer (this);
 -      delete [] this;
 +  delete[] this;
  }
  
  void ResetStateEvent::print() {