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

Unified Diff: third_party/WebKit/Source/wtf/Allocator.h

Issue 1412083007: Remove FastAllocBase.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
Index: third_party/WebKit/Source/wtf/Allocator.h
diff --git a/third_party/WebKit/Source/wtf/Allocator.h b/third_party/WebKit/Source/wtf/Allocator.h
index 5b39698e5abc1a71762f0fffc422df4cacf945b6..c728afe09b9b26aa85a070793deaf806af5f0463 100644
--- a/third_party/WebKit/Source/wtf/Allocator.h
+++ b/third_party/WebKit/Source/wtf/Allocator.h
@@ -5,6 +5,8 @@
#ifndef WTF_Allocator_h
#define WTF_Allocator_h
+#include "wtf/Assertions.h"
+#include "wtf/Partitions.h"
#include "wtf/StdLibExtras.h"
namespace WTF {
@@ -69,6 +71,60 @@ namespace WTF {
#define STACK_ALLOCATED() DISALLOW_ALLOCATION()
#endif
+// Provides customizable overrides of fastMalloc/fastFree and operator new/delete
+//
+// Provided functionality:
+// Macro: WTF_MAKE_FAST_ALLOCATED
+//
+// Example usage:
+// class Widget {
+// WTF_MAKE_FAST_ALLOCATED(Widget)
+// ...
+// };
+//
+// struct Data {
+// WTF_MAKE_FAST_ALLOCATED(Data)
+// public:
+// ...
+// };
+//
+
+#define WTF_MAKE_FAST_ALLOCATED(type) \
+public: \
+ void* operator new(size_t, void* p) { return p; } \
+ void* operator new[](size_t, void* p) { return p; } \
+ \
+ void* operator new(size_t size) \
+ { \
+ return ::WTF::Partitions::fastMalloc(size); \
+ } \
+ \
+ void operator delete(void* p) \
+ { \
+ ::WTF::Partitions::fastFree(p); \
+ } \
+ \
+ void* operator new[](size_t size) \
+ { \
+ return ::WTF::Partitions::fastMalloc(size); \
+ } \
+ \
+ void operator delete[](void* p) \
+ { \
+ ::WTF::Partitions::fastFree(p); \
+ } \
+ void* operator new(size_t, NotNullTag, void* location) \
+ { \
+ ASSERT(location); \
+ return location; \
+ } \
+ static const char* classNameForAllocator() \
+ { \
+ return #type; \
+ } \
+private: \
+typedef int __thisIsHereToForceASemicolonAfterThisMacro
+
} // namespace WTF
#endif /* WTF_Allocator_h */

Powered by Google App Engine
This is Rietveld 408576698