OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WTF_Allocator_h | 5 #ifndef WTF_Allocator_h |
6 #define WTF_Allocator_h | 6 #define WTF_Allocator_h |
7 | 7 |
8 #include "wtf/Assertions.h" | 8 #include "wtf/Assertions.h" |
9 #include "wtf/Partitions.h" | 9 #include "wtf/Partitions.h" |
10 #include "wtf/StdLibExtras.h" | 10 #include "wtf/StdLibExtras.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // DISALLOW_NEW(): Cannot be allocated with new operators but can be a | 26 // DISALLOW_NEW(): Cannot be allocated with new operators but can be a |
27 // part of object. If it has Members you need a trace method and the containing | 27 // part of object. If it has Members you need a trace method and the containing |
28 // object needs to call that trace method. | 28 // object needs to call that trace method. |
29 // | 29 // |
30 // DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(): Allows only placement new operator. Thi
s | 30 // DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(): Allows only placement new operator. Thi
s |
31 // disallows general allocation of this object but allows to put the object as a | 31 // disallows general allocation of this object but allows to put the object as a |
32 // value object in collections. If these have Members you need to have a trace | 32 // value object in collections. If these have Members you need to have a trace |
33 // method. That trace method will be called automatically by the on-heap | 33 // method. That trace method will be called automatically by the on-heap |
34 // collections. | 34 // collections. |
35 // | 35 // |
36 #define DISALLOW_NEW() \ | 36 #define DISALLOW_NEW() \ |
37 private: \ | 37 private: \ |
38 void* operator new(size_t) = delete; \ | 38 void* operator new(size_t) = delete; \ |
39 void* operator new(size_t, NotNullTag, void*) = delete; \ | 39 void* operator new(size_t, NotNullTag, void*) = delete; \ |
40 void* operator new(size_t, void*) = delete; \ | 40 void* operator new(size_t, void*) = delete; \ |
41 public: | 41 public: |
42 | 42 |
43 #define DISALLOW_NEW_EXCEPT_PLACEMENT_NEW()
\ | 43 #define DISALLOW_NEW_EXCEPT_PLACEMENT_NEW()
\ |
44 public:
\ | 44 public:
\ |
45 using IsAllowOnlyInlineAllocation = int;
\ | 45 using IsAllowOnlyPlacementNew = int;
\ |
46 void* operator new(size_t, NotNullTag, void* location) { return location
; } \ | 46 void* operator new(size_t, NotNullTag, void* location) { return location
; } \ |
47 void* operator new(size_t, void* location) { return location; }
\ | 47 void* operator new(size_t, void* location) { return location; }
\ |
48 private:
\ | 48 private:
\ |
49 void* operator new(size_t) = delete;
\ | 49 void* operator new(size_t) = delete;
\ |
50 public: | 50 public: |
51 | 51 |
52 #define STATIC_ONLY(Type) \ | 52 #define STATIC_ONLY(Type) \ |
53 private: \ | 53 private: \ |
54 Type() = delete; \ | 54 Type() = delete; \ |
55 Type(const Type&) = delete; \ | 55 Type(const Type&) = delete; \ |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 static const char* classNameForAllocator() \ | 126 static const char* classNameForAllocator() \ |
127 { \ | 127 { \ |
128 return #type; \ | 128 return #type; \ |
129 } \ | 129 } \ |
130 private: \ | 130 private: \ |
131 typedef int __thisIsHereToForceASemicolonAfterThisMacro | 131 typedef int __thisIsHereToForceASemicolonAfterThisMacro |
132 | 132 |
133 } // namespace WTF | 133 } // namespace WTF |
134 | 134 |
135 #endif /* WTF_Allocator_h */ | 135 #endif /* WTF_Allocator_h */ |
OLD | NEW |