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

Unified Diff: third_party/WebKit/Source/wtf/text/CString.cpp

Issue 2565883002: Test for codegen of RELEASE_ASSERT vs CHECK in WTF (Closed)
Patch Set: . Created 4 years 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 | « third_party/WebKit/Source/wtf/text/CString.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/CString.cpp
diff --git a/third_party/WebKit/Source/wtf/text/CString.cpp b/third_party/WebKit/Source/wtf/text/CString.cpp
index 4bab024171793196ad958ed0fb567e5eb5fe3e83..1a8ce0f38c8c2701f36eab40d7a57946f34204c9 100644
--- a/third_party/WebKit/Source/wtf/text/CString.cpp
+++ b/third_party/WebKit/Source/wtf/text/CString.cpp
@@ -50,6 +50,20 @@ PassRefPtr<CStringImpl> CStringImpl::createUninitialized(size_t length,
return adoptRef(new (buffer) CStringImpl(length));
}
+PassRefPtr<CStringImpl> CStringImpl::createUninitializedCHECK(size_t length,
+ char*& data) {
+ // TODO(esprehn): This doesn't account for the NUL.
+ CHECK_LT(length, (numeric_limits<unsigned>::max() - sizeof(CStringImpl)));
+
+ // The +1 is for the terminating NUL character.
+ size_t size = sizeof(CStringImpl) + length + 1;
+ CStringImpl* buffer = static_cast<CStringImpl*>(
+ Partitions::bufferMalloc(size, WTF_HEAP_PROFILER_TYPE_NAME(CStringImpl)));
+ data = reinterpret_cast<char*>(buffer + 1);
+ data[length] = '\0';
+ return adoptRef(new (buffer) CStringImpl(length));
+}
+
void CStringImpl::operator delete(void* ptr) {
Partitions::bufferFree(ptr);
}
@@ -60,7 +74,11 @@ CString::CString(const char* chars, size_t length) {
return;
}
char* data;
- m_buffer = CStringImpl::createUninitialized(length, data);
+ if (rand() % 2) {
+ m_buffer = CStringImpl::createUninitialized(length, data);
+ } else {
+ m_buffer = CStringImpl::createUninitializedCHECK(length, data);
+ }
memcpy(data, chars, length);
}
« no previous file with comments | « third_party/WebKit/Source/wtf/text/CString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698