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

Unified Diff: src/zone/zone.cc

Issue 2377943003: Fixed zapping of contents (Closed)
Patch Set: Reaction to comments Created 4 years, 3 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 | « src/zone/accounting-allocator.cc ('k') | src/zone/zone-segment.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/zone/zone.cc
diff --git a/src/zone/zone.cc b/src/zone/zone.cc
index 91506dd6d206fbba28653483de5beca4011cc9d5..4272e17fd2eba2ef2389350b15ae05fd6abfed31 100644
--- a/src/zone/zone.cc
+++ b/src/zone/zone.cc
@@ -92,11 +92,6 @@ void* Zone::New(size_t size) {
}
void Zone::DeleteAll() {
-#ifdef DEBUG
- // Constant byte value used for zapping dead memory in debug mode.
- static const unsigned char kZapDeadByte = 0xcd;
-#endif
-
// Find a segment with a suitable size to keep around.
Segment* keep = nullptr;
// Traverse the chained list of segments, zapping (in debug mode)
@@ -112,9 +107,8 @@ void Zone::DeleteAll() {
#ifdef DEBUG
// Un-poison first so the zapping doesn't trigger ASan complaints.
ASAN_UNPOISON_MEMORY_REGION(current, size);
- // Zap the entire current segment (including the header).
- memset(current, kZapDeadByte, size);
#endif
+ current->ZapContents();
segment_bytes_allocated_ -= size;
allocator_->FreeSegment(current);
}
@@ -131,10 +125,7 @@ void Zone::DeleteAll() {
limit_ = keep->end();
// Un-poison so we can re-use the segment later.
ASAN_UNPOISON_MEMORY_REGION(start, keep->capacity());
Michael Lippautz 2016/09/29 09:44:47 All other unpoison operations are within #ifdef DE
-#ifdef DEBUG
- // Zap the contents of the kept segment (but not the header).
- memset(start, kZapDeadByte, keep->capacity());
-#endif
+ keep->ZapContents();
} else {
position_ = limit_ = 0;
}
@@ -145,20 +136,14 @@ void Zone::DeleteAll() {
}
void Zone::DeleteKeptSegment() {
-#ifdef DEBUG
- // Constant byte value used for zapping dead memory in debug mode.
- static const unsigned char kZapDeadByte = 0xcd;
-#endif
-
DCHECK(segment_head_ == nullptr || segment_head_->next() == nullptr);
if (segment_head_ != nullptr) {
size_t size = segment_head_->size();
#ifdef DEBUG
// Un-poison first so the zapping doesn't trigger ASan complaints.
ASAN_UNPOISON_MEMORY_REGION(segment_head_, size);
- // Zap the entire kept segment (including the header).
- memset(segment_head_, kZapDeadByte, size);
#endif
+ segment_head_->ZapContents();
segment_bytes_allocated_ -= size;
allocator_->FreeSegment(segment_head_);
segment_head_ = nullptr;
« no previous file with comments | « src/zone/accounting-allocator.cc ('k') | src/zone/zone-segment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698