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

Unified Diff: Source/wtf/ArrayBufferContents.cpp

Issue 18316003: Revert "Use V8 implementation of ArrayBuffer in Blink." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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/wtf/ArrayBufferContents.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/ArrayBufferContents.cpp
diff --git a/Source/wtf/ArrayBufferContents.cpp b/Source/wtf/ArrayBufferContents.cpp
index de9d67e773931cb58d87ff1237108b80d0f56831..1d0abd148c214744951b4d755496b15206354cd1 100644
--- a/Source/wtf/ArrayBufferContents.cpp
+++ b/Source/wtf/ArrayBufferContents.cpp
@@ -52,21 +52,24 @@ ArrayBufferContents::ArrayBufferContents(unsigned numElements, unsigned elementB
return;
}
}
- if (allocateMemory(numElements * elementByteSize, policy, m_data)) {
+ bool allocationSucceeded = false;
+ if (policy == ZeroInitialize)
+ allocationSucceeded = WTF::tryFastCalloc(numElements, elementByteSize).getValue(m_data);
+ else {
+ ASSERT(policy == DontInitialize);
+ allocationSucceeded = WTF::tryFastMalloc(numElements * elementByteSize).getValue(m_data);
+ }
+
+ if (allocationSucceeded) {
m_sizeInBytes = numElements * elementByteSize;
return;
}
m_data = 0;
}
-ArrayBufferContents::ArrayBufferContents(void* data, unsigned sizeInBytes)
- : m_data(data)
- , m_sizeInBytes(sizeInBytes)
- , m_deallocationObserver(0) { }
-
ArrayBufferContents::~ArrayBufferContents()
{
- freeMemory(m_data);
+ WTF::fastFree(m_data);
clear();
}
@@ -87,18 +90,4 @@ void ArrayBufferContents::transfer(ArrayBufferContents& other)
clear();
}
-bool ArrayBufferContents::allocateMemory(size_t size, InitializationPolicy policy, void*& data)
-{
- if (policy == ZeroInitialize) {
- return WTF::tryFastCalloc(size, 1).getValue(data);
- }
- ASSERT(policy == DontInitialize);
- return WTF::tryFastMalloc(size).getValue(data);
-}
-
-void ArrayBufferContents::freeMemory(void * data)
-{
- WTF::fastFree(data);
-}
-
} // namespace WTF
« no previous file with comments | « Source/wtf/ArrayBufferContents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698