Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1666)

Side by Side Diff: third_party/re2/util/sparse_set.h

Issue 149723005: Patch re2 to support MSan. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006 The RE2 Authors. All Rights Reserved. 1 // Copyright 2006 The RE2 Authors. All Rights Reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // DESCRIPTION 5 // DESCRIPTION
6 // 6 //
7 // SparseSet<T>(m) is a set of integers in [0, m). 7 // SparseSet<T>(m) is a set of integers in [0, m).
8 // It requires sizeof(int)*m memory, but it provides 8 // It requires sizeof(int)*m memory, but it provides
9 // fast iteration through the elements in the set and fast clearing 9 // fast iteration through the elements in the set and fast clearing
10 // of the set. 10 // of the set.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #ifndef RE2_UTIL_SPARSE_SET_H__ 47 #ifndef RE2_UTIL_SPARSE_SET_H__
48 #define RE2_UTIL_SPARSE_SET_H__ 48 #define RE2_UTIL_SPARSE_SET_H__
49 49
50 #include "util/util.h" 50 #include "util/util.h"
51 51
52 namespace re2 { 52 namespace re2 {
53 53
54 class SparseSet { 54 class SparseSet {
55 public: 55 public:
56 SparseSet() 56 SparseSet()
57 : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL), valgrind_(Ru nningOnValgrind()) {} 57 : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL),
58 #if defined(MEMORY_SANITIZER)
59 valgrind_(true)
60 #else
61 valgrind_(RunningOnValgrind())
62 #endif
63 {
64 }
58 65
59 SparseSet(int max_size) { 66 SparseSet(int max_size) {
60 max_size_ = max_size; 67 max_size_ = max_size;
61 sparse_to_dense_ = new int[max_size]; 68 sparse_to_dense_ = new int[max_size];
62 dense_ = new int[max_size]; 69 dense_ = new int[max_size];
70 #if defined(MEMORY_SANITIZER)
71 valgrind_ = true;
72 #else
63 valgrind_ = RunningOnValgrind(); 73 valgrind_ = RunningOnValgrind();
74 #endif
64 // Don't need to zero the memory, but do so anyway 75 // Don't need to zero the memory, but do so anyway
65 // to appease Valgrind. 76 // to appease Valgrind.
66 if (valgrind_) { 77 if (valgrind_) {
67 for (int i = 0; i < max_size; i++) { 78 for (int i = 0; i < max_size; i++) {
68 dense_[i] = 0xababababU; 79 dense_[i] = 0xababababU;
69 sparse_to_dense_[i] = 0xababababU; 80 sparse_to_dense_[i] = 0xababababU;
70 } 81 }
71 } 82 }
72 size_ = 0; 83 size_ = 0;
73 } 84 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 int* sparse_to_dense_; 181 int* sparse_to_dense_;
171 int* dense_; 182 int* dense_;
172 bool valgrind_; 183 bool valgrind_;
173 184
174 DISALLOW_EVIL_CONSTRUCTORS(SparseSet); 185 DISALLOW_EVIL_CONSTRUCTORS(SparseSet);
175 }; 186 };
176 187
177 } // namespace re2 188 } // namespace re2
178 189
179 #endif // RE2_UTIL_SPARSE_SET_H__ 190 #endif // RE2_UTIL_SPARSE_SET_H__
OLDNEW
« third_party/re2/util/sparse_array.h ('K') | « third_party/re2/util/sparse_array.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698