| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // PagedArray implements an array stored using many fixed-size pages. | 5 // PagedArray implements an array stored using many fixed-size pages. |
| 6 // | 6 // |
| 7 // PagedArray is a work-around to allow large arrays to be allocated when there | 7 // PagedArray is a work-around to allow large arrays to be allocated when there |
| 8 // is too much address space fragmentation for allocating the large arrays as | 8 // is too much address space fragmentation for allocating the large arrays as |
| 9 // contigous arrays. | 9 // contigous arrays. |
| 10 | 10 |
| 11 #ifndef COURGETTE_BSDIFF_PAGED_ARRAY_H_ | 11 #ifndef COURGETTE_BSDIFF_PAGED_ARRAY_H_ |
| 12 #define COURGETTE_BSDIFF_PAGED_ARRAY_H_ | 12 #define COURGETTE_BSDIFF_PAGED_ARRAY_H_ |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include <stddef.h> |
| 15 |
| 16 #include "base/macros.h" |
| 15 #include "base/process/memory.h" | 17 #include "base/process/memory.h" |
| 16 | 18 |
| 17 namespace courgette { | 19 namespace courgette { |
| 18 | 20 |
| 19 // PagedArray implements an array stored using many fixed-size pages. | 21 // PagedArray implements an array stored using many fixed-size pages. |
| 20 template<typename T> | 22 template<typename T> |
| 21 class PagedArray { | 23 class PagedArray { |
| 22 enum { | 24 enum { |
| 23 // Page size in elements. Page size of 2^18 * sizeof(T) is 1MB for T = int. | 25 // Page size in elements. Page size of 2^18 * sizeof(T) is 1MB for T = int. |
| 24 kLogPageSize = 18, | 26 kLogPageSize = 18, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 75 } |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 T** pages_; | 78 T** pages_; |
| 77 size_t page_count_; | 79 size_t page_count_; |
| 78 | 80 |
| 79 DISALLOW_COPY_AND_ASSIGN(PagedArray); | 81 DISALLOW_COPY_AND_ASSIGN(PagedArray); |
| 80 }; | 82 }; |
| 81 } // namespace | 83 } // namespace |
| 82 #endif // COURGETTE_BSDIFF_PAGED_ARRAY_H_ | 84 #endif // COURGETTE_BSDIFF_PAGED_ARRAY_H_ |
| OLD | NEW |