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

Unified Diff: Source/wtf/RawPtr.h

Issue 209433004: Do not zero-initialize RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compilation on gcc and msvc Created 6 years, 9 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 | « Source/modules/webdatabase/WorkerGlobalScopeWebDatabase.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/RawPtr.h
diff --git a/Source/wtf/RawPtr.h b/Source/wtf/RawPtr.h
index d0c0d8019a83e3cce36f73ddce76dd1df058bdf4..f37ffd5aa48b3a2f254c7e69cc91ff945acf1b05 100644
--- a/Source/wtf/RawPtr.h
+++ b/Source/wtf/RawPtr.h
@@ -32,6 +32,8 @@
#define WTF_RawPtr_h
#include <algorithm>
+#include <stdint.h>
+
#include "wtf/HashTableDeletedValueType.h"
// RawPtr is a simple wrapper for a raw pointer that provides the
@@ -48,7 +50,12 @@ class RawPtr {
WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(RawPtr);
WTF_DISALLOW_ZERO_ASSIGNMENT(RawPtr);
public:
- RawPtr() : m_ptr(0) { }
+ RawPtr()
+ {
+#ifndef NDEBUG
+ m_ptr = reinterpret_cast<T*>(rawPtrZapValue);
+#endif
+ }
RawPtr(std::nullptr_t) : m_ptr(0) { }
RawPtr(T* ptr) : m_ptr(ptr) { }
explicit RawPtr(T& reference) : m_ptr(&reference) { }
@@ -116,6 +123,7 @@ public:
static T* hashTableDeletedValue() { return reinterpret_cast<T*>(-1); }
private:
+ static const uintptr_t rawPtrZapValue = 0x3a3a3a3a;
T* m_ptr;
};
« no previous file with comments | « Source/modules/webdatabase/WorkerGlobalScopeWebDatabase.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698