Index: Source/wtf/Vector.h |
diff --git a/Source/wtf/Vector.h b/Source/wtf/Vector.h |
index 4eefbcb3d09419dc98143a5afd1c9bff06b36be6..a2e7895a539517a4e72e68243950a2b96a487b7f 100644 |
--- a/Source/wtf/Vector.h |
+++ b/Source/wtf/Vector.h |
@@ -28,7 +28,7 @@ |
#include "wtf/StdLibExtras.h" |
#include "wtf/UnusedParam.h" |
#include "wtf/VectorTraits.h" |
-#include <limits> |
+#include "wtf/WTF.h" |
#include <utility> |
#include <string.h> |
@@ -254,12 +254,17 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE; |
class VectorBufferBase { |
WTF_MAKE_NONCOPYABLE(VectorBufferBase); |
public: |
+ size_t roundSize(size_t size) |
+ { |
+ return (size + 7) & ~7; |
+ } |
+ |
void allocateBuffer(size_t newCapacity) |
{ |
ASSERT(newCapacity); |
- // Using "unsigned" is not a limitation because Chromium's max malloc() is 2GB even on 64-bit. |
- RELEASE_ASSERT(newCapacity <= std::numeric_limits<unsigned>::max() / sizeof(T)); |
- size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T)); |
+ RELEASE_ASSERT(newCapacity <= WTF::QuantizedAllocation::kMaxUnquantizedAllocation / sizeof(T)); |
abarth-chromium
2013/09/07 05:08:24
WTF:: <-- no need for WTF prefix inside WTF.
|
+ size_t origSizeToAllocate = newCapacity * sizeof(T); |
abarth-chromium
2013/09/07 05:08:24
origSizeToAllocate ---> originalSizeToAllocate
Pl
|
+ size_t sizeToAllocate = WTF::QuantizedAllocation::quantizedSize(origSizeToAllocate); |
m_capacity = sizeToAllocate / sizeof(T); |
m_buffer = static_cast<T*>(fastMalloc(sizeToAllocate)); |
} |
@@ -272,9 +277,9 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE; |
void reallocateBuffer(size_t newCapacity) |
{ |
ASSERT(shouldReallocateBuffer(newCapacity)); |
- // Using "unsigned" is not a limitation because Chromium's max malloc() is 2GB even on 64-bit. |
- RELEASE_ASSERT(newCapacity <= std::numeric_limits<unsigned>::max() / sizeof(T)); |
- size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T)); |
+ RELEASE_ASSERT(newCapacity <= WTF::QuantizedAllocation::kMaxUnquantizedAllocation / sizeof(T)); |
+ size_t origSizeToAllocate = newCapacity * sizeof(T); |
+ size_t sizeToAllocate = WTF::QuantizedAllocation::quantizedSize(origSizeToAllocate); |
m_capacity = sizeToAllocate / sizeof(T); |
m_buffer = static_cast<T*>(fastRealloc(m_buffer, sizeToAllocate)); |
} |