| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Paul Pedriana <ppedriana@ea.com>. All rights reserve
d. | 2 * Copyright (C) 2008, 2009 Paul Pedriana <ppedriana@ea.com>. All rights reserve
d. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // ... | 40 // ... |
| 41 // }; | 41 // }; |
| 42 // | 42 // |
| 43 // struct Data { | 43 // struct Data { |
| 44 // WTF_MAKE_FAST_ALLOCATED | 44 // WTF_MAKE_FAST_ALLOCATED |
| 45 // public: | 45 // public: |
| 46 // ... | 46 // ... |
| 47 // }; | 47 // }; |
| 48 // | 48 // |
| 49 | 49 |
| 50 #include <new> | |
| 51 #include <stdint.h> | |
| 52 #include "wtf/Assertions.h" | 50 #include "wtf/Assertions.h" |
| 53 #include "wtf/FastMalloc.h" | 51 #include "wtf/FastMalloc.h" |
| 54 #include "wtf/StdLibExtras.h" | 52 #include "wtf/StdLibExtras.h" |
| 55 | 53 |
| 56 #define WTF_MAKE_FAST_ALLOCATED \ | 54 #define WTF_MAKE_FAST_ALLOCATED \ |
| 57 public: \ | 55 public: \ |
| 58 void* operator new(size_t, void* p) { return p; } \ | 56 void* operator new(size_t, void* p) { return p; } \ |
| 59 void* operator new[](size_t, void* p) { return p; } \ | 57 void* operator new[](size_t, void* p) { return p; } \ |
| 60 \ | 58 \ |
| 61 void* operator new(size_t size) \ | 59 void* operator new(size_t size) \ |
| 62 { \ | 60 { \ |
| 63 void* p = ::WTF::fastMalloc(size); \ | 61 return ::WTF::fastMalloc(size); \ |
| 64 ::WTF::fastMallocMatchValidateMalloc(p, ::WTF::Internal::AllocTypeClass
New); \ | |
| 65 return p; \ | |
| 66 } \ | 62 } \ |
| 67 \ | 63 \ |
| 68 void operator delete(void* p) \ | 64 void operator delete(void* p) \ |
| 69 { \ | 65 { \ |
| 70 ::WTF::fastMallocMatchValidateFree(p, ::WTF::Internal::AllocTypeClassNew
); \ | |
| 71 ::WTF::fastFree(p); \ | 66 ::WTF::fastFree(p); \ |
| 72 } \ | 67 } \ |
| 73 \ | 68 \ |
| 74 void* operator new[](size_t size) \ | 69 void* operator new[](size_t size) \ |
| 75 { \ | 70 { \ |
| 76 void* p = ::WTF::fastMalloc(size); \ | 71 return ::WTF::fastMalloc(size); \ |
| 77 ::WTF::fastMallocMatchValidateMalloc(p, ::WTF::Internal::AllocTypeClassN
ewArray); \ | |
| 78 return p; \ | |
| 79 } \ | 72 } \ |
| 80 \ | 73 \ |
| 81 void operator delete[](void* p) \ | 74 void operator delete[](void* p) \ |
| 82 { \ | 75 { \ |
| 83 ::WTF::fastMallocMatchValidateFree(p, ::WTF::Internal::AllocTypeClassNe
wArray); \ | |
| 84 ::WTF::fastFree(p); \ | 76 ::WTF::fastFree(p); \ |
| 85 } \ | 77 } \ |
| 86 void* operator new(size_t, NotNullTag, void* location) \ | 78 void* operator new(size_t, NotNullTag, void* location) \ |
| 87 { \ | 79 { \ |
| 88 ASSERT(location); \ | 80 ASSERT(location); \ |
| 89 return location; \ | 81 return location; \ |
| 90 } \ | 82 } \ |
| 91 private: \ | 83 private: \ |
| 92 typedef int __thisIsHereToForceASemicolonAfterThisMacro | 84 typedef int __thisIsHereToForceASemicolonAfterThisMacro |
| 93 | 85 |
| 94 #endif // FastAllocBase_h | 86 #endif // FastAllocBase_h |
| OLD | NEW |