Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: switch to xxhash as a (fast) hashing function.
[simgrid.git] / src / mc / sosp / ChunkedData.hpp
index c904a29..ac4e24a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2019. 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. */
@@ -6,13 +6,10 @@
 #ifndef SIMGRID_MC_CHUNKED_DATA_HPP
 #define SIMGRID_MC_CHUNKED_DATA_HPP
 
-#include <cstddef>
-#include <cstdint>
-
-#include <utility>
 #include <vector>
 
 #include "src/mc/mc_forward.hpp"
+#include "src/mc/remote/RemotePtr.hpp"
 #include "src/mc/sosp/PageStore.hpp"
 
 namespace simgrid {
@@ -22,7 +19,7 @@ namespace mc {
  *
  *  In order to save memory when taking memory snapshots, a given byte-string
  *  is split in fixed-size chunks. Identical chunks (either from the same
- *  snapshot or more probably from different snpashots) share the same memory
+ *  snapshot or more probably from different snapshots) share the same memory
  *  storage.
  *
  *  Thus a chunked is represented as a sequence of indices of each chunk.
@@ -56,11 +53,13 @@ public:
   }
   ChunkedData& operator=(ChunkedData const& that)
   {
-    this->clear();
-    store_   = that.store_;
-    pagenos_ = that.pagenos_;
-    for (std::size_t const& pageno : pagenos_)
-      store_->ref_page(pageno);
+    if (this != &that) {
+      this->clear();
+      store_   = that.store_;
+      pagenos_ = that.pagenos_;
+      for (std::size_t const& pageno : pagenos_)
+        store_->ref_page(pageno);
+    }
     return *this;
   }
   ChunkedData& operator=(ChunkedData&& that)