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

Unified Diff: src/circular-queue.cc

Issue 3251004: Fix a error in SamplingCircularQueue found using Valgrind memcheck. (Closed)
Patch Set: Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/circular-queue.cc
diff --git a/src/circular-queue.cc b/src/circular-queue.cc
index af650de5e79fcd17b21c94d208322274c9f578f0..928c3f0c05ecf8d09b3112cf6c7e5cbab0990bb8 100644
--- a/src/circular-queue.cc
+++ b/src/circular-queue.cc
@@ -47,8 +47,9 @@ SamplingCircularQueue::SamplingCircularQueue(int record_size_in_bytes,
producer_consumer_distance_(2 * chunk_size_),
buffer_(NewArray<Cell>(buffer_size_ + 1)) {
ASSERT(buffer_size_in_chunks > 2);
- // Only need to keep the first cell of a chunk clean.
- for (int i = 0; i < buffer_size_; i += chunk_size_) {
+ // Clean up the whole buffer to avoid encountering a random kEnd
+ // while enqueuing.
+ for (int i = 0; i < buffer_size_; ++i) {
buffer_[i] = kClear;
}
buffer_[buffer_size_] = kEnd;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698