OLD | NEW |
1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
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 are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * 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 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | 29 |
30 // --- | 30 // --- |
31 // Author: Sanjay Ghemawat <opensource@google.com> | 31 // Author: Sanjay Ghemawat <opensource@google.com> |
32 | 32 |
33 #ifndef TCMALLOC_PAGE_HEAP_ALLOCATOR_H_ | 33 #ifndef TCMALLOC_PAGE_HEAP_ALLOCATOR_H_ |
34 #define TCMALLOC_PAGE_HEAP_ALLOCATOR_H_ | 34 #define TCMALLOC_PAGE_HEAP_ALLOCATOR_H_ |
35 | 35 |
| 36 #include <stddef.h> // for NULL, size_t |
| 37 |
| 38 #include "common.h" // for MetaDataAlloc |
| 39 #include "internal_logging.h" // for ASSERT, CRASH |
| 40 |
36 namespace tcmalloc { | 41 namespace tcmalloc { |
37 | 42 |
38 // Simple allocator for objects of a specified type. External locking | 43 // Simple allocator for objects of a specified type. External locking |
39 // is required before accessing one of these objects. | 44 // is required before accessing one of these objects. |
40 template <class T> | 45 template <class T> |
41 class PageHeapAllocator { | 46 class PageHeapAllocator { |
42 public: | 47 public: |
43 // We use an explicit Init function because these variables are statically | 48 // We use an explicit Init function because these variables are statically |
44 // allocated and their constructors might not have run by the time some | 49 // allocated and their constructors might not have run by the time some |
45 // other static variable tries to allocate memory. | 50 // other static variable tries to allocate memory. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Free list of already carved objects | 103 // Free list of already carved objects |
99 void* free_list_; | 104 void* free_list_; |
100 | 105 |
101 // Number of allocated but unfreed objects | 106 // Number of allocated but unfreed objects |
102 int inuse_; | 107 int inuse_; |
103 }; | 108 }; |
104 | 109 |
105 } // namespace tcmalloc | 110 } // namespace tcmalloc |
106 | 111 |
107 #endif // TCMALLOC_PAGE_HEAP_ALLOCATOR_H_ | 112 #endif // TCMALLOC_PAGE_HEAP_ALLOCATOR_H_ |
OLD | NEW |