Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use RAII std::string for s_mc_comm_pattern::rdv
[simgrid.git] / src / mc / mc_comm_pattern.h
index 285256a..1fd9774 100644 (file)
@@ -7,7 +7,10 @@
 #ifndef SIMGRID_MC_COMM_PATTERN_H
 #define SIMGRID_MC_COMM_PATTERN_H
 
-#include <stddef.h>
+#include <cstddef>
+#include <cstring>
+
+#include <string>
 
 #include <simgrid_config.h>
 #include <xbt/dynar.h>
 #include "src/smpi/private.h"
 #include <smpi/smpi.h>
 
-#include "mc_state.h"
+#include "src/mc/mc_state.h"
 
 SG_BEGIN_DECL()
 
 typedef struct s_mc_comm_pattern{
-  int num;
+  int num = 0;
   smx_synchro_t comm_addr;
-  e_smx_comm_type_t type;
-  unsigned long src_proc;
-  unsigned long dst_proc;
-  const char *src_host;
-  const char *dst_host;
-  char *rdv;
-  ssize_t data_size;
-  void *data;
-  int tag;
-  int index;
+  e_smx_comm_type_t type = SIMIX_COMM_SEND;
+  unsigned long src_proc = 0;
+  unsigned long dst_proc = 0;
+  const char *src_host = nullptr;
+  const char *dst_host = nullptr;
+  std::string rdv;
+  ssize_t data_size = 0;
+  void *data = nullptr;
+  int tag = 0;
+  int index = 0;
+
+  s_mc_comm_pattern()
+  {
+    std::memset(&comm_addr, 0, sizeof(comm_addr));
+  }
+  ~s_mc_comm_pattern()
+  {
+    xbt_free(this->data);
+  }
+
+  // No copy:
+  s_mc_comm_pattern(s_mc_comm_pattern const&) = delete;
+  s_mc_comm_pattern& operator=(s_mc_comm_pattern const&) = delete;
+
 } s_mc_comm_pattern_t, *mc_comm_pattern_t;
 
 typedef struct s_mc_list_comm_pattern{
@@ -90,15 +107,14 @@ XBT_PRIVATE void MC_handle_comm_pattern(e_mc_call_type_t call_type, smx_simcall_
 XBT_PRIVATE void MC_comm_pattern_free_voidp(void *p);
 XBT_PRIVATE void MC_list_comm_pattern_free_voidp(void *p);
 XBT_PRIVATE void MC_complete_comm_pattern(xbt_dynar_t list, smx_synchro_t comm_addr, unsigned int issuer, int backtracking);
-int MC_modelcheck_comm_determinism(void);
 
-XBT_PRIVATE void MC_restore_communications_pattern(mc_state_t state);
+XBT_PRIVATE void MC_restore_communications_pattern(simgrid::mc::State* state);
 
 XBT_PRIVATE mc_comm_pattern_t MC_comm_pattern_dup(mc_comm_pattern_t comm);
 XBT_PRIVATE xbt_dynar_t MC_comm_patterns_dup(xbt_dynar_t state);
 
-XBT_PRIVATE void MC_state_copy_incomplete_communications_pattern(mc_state_t state);
-XBT_PRIVATE void MC_state_copy_index_communications_pattern(mc_state_t state);
+XBT_PRIVATE void MC_state_copy_incomplete_communications_pattern(simgrid::mc::State* state);
+XBT_PRIVATE void MC_state_copy_index_communications_pattern(simgrid::mc::State* state);
 
 XBT_PRIVATE void MC_comm_pattern_free(mc_comm_pattern_t p);