OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CUSTOM_ALLOCATOR_H_ |
| 6 #define CUSTOM_ALLOCATOR_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 |
| 10 // PERFTOOLS_DLL_DECL is unnecessary, as it is Windows specific. |
| 11 |
| 12 // A container class for using LowLevelAlloc with STL_Allocator. The functions |
| 13 // Allocate() and Free() must match the specificiations in STL_Allocator. |
| 14 class CustomAllocator { |
| 15 public: |
| 16 // This is a stateless class, but there is static data within the module that |
| 17 // needs to be created and deleted. |
| 18 static void Initialize(); |
| 19 static bool Shutdown(); |
| 20 static bool IsInitialized(); |
| 21 |
| 22 // Special initialization for unit testing. Uses new/delete for allocations. |
| 23 static void InitializeForUnitTest(); |
| 24 |
| 25 static void* Allocate(size_t size); |
| 26 static void Free(void* ptr, size_t size); |
| 27 }; |
| 28 |
| 29 #endif // CUSTOM_ALLOCATOR_H_ |
OLD | NEW |