Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / wtf / DefaultAllocator.h
index e4e8e78..9be80e3 100644 (file)
@@ -66,19 +66,19 @@ public:
     struct VectorBackingHelper {
         typedef void Type;
     };
-    template<typename T, typename U, typename V, typename W, typename X>
+    template<typename T>
     struct HashTableBackingHelper {
         typedef void Type;
     };
     template <typename Return, typename Metadata>
     static Return backingMalloc(size_t size)
     {
-        return reinterpret_cast<Return>(partitionAllocGeneric(Partitions::getBufferPartition(), size));
+        return reinterpret_cast<Return>(backingAllocate(size));
     }
     template <typename Return, typename Metadata>
     static Return zeroedBackingMalloc(size_t size)
     {
-        void* result = partitionAllocGeneric(Partitions::getBufferPartition(), size);
+        void* result = backingAllocate(size);
         memset(result, 0, size);
         return reinterpret_cast<Return>(result);
     }
@@ -87,10 +87,7 @@ public:
     {
         return reinterpret_cast<Return>(fastMalloc(size));
     }
-    static void backingFree(void* address)
-    {
-        partitionFreeGeneric(Partitions::getBufferPartition(), address);
-    }
+    WTF_EXPORT static void backingFree(void* address);
     static void free(void* address)
     {
         fastFree(address);
@@ -132,6 +129,9 @@ public:
     {
         return *other;
     }
+
+private:
+    WTF_EXPORT static void* backingAllocate(size_t);
 };
 
 // The Windows compiler seems to be very eager to instantiate things it won't
@@ -147,6 +147,23 @@ public:
 
 } // namespace WTF
 
+#define WTF_USE_ALLOCATOR(ClassName, Allocator) \
+public: \
+    void* operator new(size_t size) \
+    { \
+        return Allocator::template malloc<void*, ClassName>(size); \
+    } \
+    void operator delete(void* p) { Allocator::free(p); } \
+    void* operator new[](size_t size) { return Allocator::template newArray<ClassName>(size); } \
+    void operator delete[](void* p) { Allocator::deleteArray(p); } \
+    void* operator new(size_t, NotNullTag, void* location) \
+    { \
+        ASSERT(location); \
+        return location; \
+    } \
+private: \
+typedef int __thisIsHereToForceASemicolonAfterThisMacro
+
 using WTF::DefaultAllocator;
 
 #endif // WTF_DefaultAllocator_h