Check WTF::Vector size with '0' inline capacity
authormikhail.pozdnyakov@intel.com <mikhail.pozdnyakov@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2013 08:20:23 +0000 (08:20 +0000)
committermikhail.pozdnyakov@intel.com <mikhail.pozdnyakov@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2013 08:20:23 +0000 (08:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=119397

Reviewed by Andreas Kling.

Putting in place the compile assertion that had been removed with r153514.

* wtf/SizeLimits.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153638 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/SizeLimits.cpp

index 55dfb54..39a05a5 100644 (file)
@@ -1,3 +1,14 @@
+2013-08-02  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        Check WTF::Vector size with '0' inline capacity
+        https://bugs.webkit.org/show_bug.cgi?id=119397
+
+        Reviewed by Andreas Kling.
+
+        Putting in place the compile assertion that had been removed with r153514.
+
+        * wtf/SizeLimits.cpp:
+
 2013-07-26  Mark Rowe  <mrowe@apple.com>
 
         <http://webkit.org/b/119169> RetainPtr should support ARC for Objective-C objects.
index 538f460..ab2b100 100644 (file)
@@ -54,11 +54,19 @@ struct SameSizeAsRefCounted {
     // Don't add anything here because this should stay small.
 };
 #endif
-template<typename T, unsigned inlineCapacity>
-struct SameSizeAsVectorWithInlineCapacity {
+template<typename T, unsigned inlineCapacity = 0>
+struct SameSizeAsVectorWithInlineCapacity;
+
+template<typename T>
+struct SameSizeAsVectorWithInlineCapacity<T, 0> {
     void* bufferPointer;
     unsigned capacity;
     unsigned size;
+};
+
+template<typename T, unsigned inlineCapacity>
+struct SameSizeAsVectorWithInlineCapacity {
+    SameSizeAsVectorWithInlineCapacity<T, 0> baseCapacity;
     AlignedBuffer<inlineCapacity * sizeof(T), WTF_ALIGN_OF(T)> inlineBuffer;
 };
 
@@ -67,6 +75,7 @@ COMPILE_ASSERT(sizeof(PassRefPtr<RefCounted<int> >) == sizeof(int*), PassRefPtr_
 COMPILE_ASSERT(sizeof(RefCounted<int>) == sizeof(SameSizeAsRefCounted), RefCounted_should_stay_small);
 COMPILE_ASSERT(sizeof(RefCountedCustomAllocated<int>) == sizeof(SameSizeAsRefCounted), RefCountedCustomAllocated_should_stay_small);
 COMPILE_ASSERT(sizeof(RefPtr<RefCounted<int> >) == sizeof(int*), RefPtr_should_stay_small);
+COMPILE_ASSERT(sizeof(Vector<int>) == sizeof(SameSizeAsVectorWithInlineCapacity<int>), Vector_should_stay_small);
 COMPILE_ASSERT(sizeof(Vector<int, 1>) == sizeof(SameSizeAsVectorWithInlineCapacity<int, 1>), Vector_should_stay_small);
 COMPILE_ASSERT(sizeof(Vector<int, 2>) == sizeof(SameSizeAsVectorWithInlineCapacity<int, 2>), Vector_should_stay_small);
 COMPILE_ASSERT(sizeof(Vector<int, 3>) == sizeof(SameSizeAsVectorWithInlineCapacity<int, 3>), Vector_should_stay_small);