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 // contiguous arrays. |
10 | 10 |
11 #ifndef COURGETTE_BSDIFF_PAGED_ARRAY_H_ | 11 #ifndef COURGETTE_BSDIFF_PAGED_ARRAY_H_ |
huangs
2016/05/13 03:56:47
Should these be modified? I don't know what the co
altimin
2016/05/13 13:16:57
Done.
| |
12 #define COURGETTE_BSDIFF_PAGED_ARRAY_H_ | 12 #define COURGETTE_BSDIFF_PAGED_ARRAY_H_ |
13 | 13 |
14 #include <stddef.h> | 14 #include <stddef.h> |
15 | 15 |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/process/memory.h" | 17 #include "base/process/memory.h" |
18 | 18 |
19 namespace courgette { | 19 namespace courgette { |
20 | 20 |
21 // PagedArray implements an array stored using many fixed-size pages. | 21 // PagedArray implements an array stored using many fixed-size pages. |
22 template<typename T> | 22 template <typename T> |
23 class PagedArray { | 23 class PagedArray { |
24 enum { | 24 enum { |
25 // 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. |
26 kLogPageSize = 18, | 26 kLogPageSize = 18, |
27 kPageSize = 1 << kLogPageSize | 27 kPageSize = 1 << kLogPageSize |
28 }; | 28 }; |
29 | 29 |
30 public: | 30 public: |
31 PagedArray() : pages_(NULL), page_count_(0) {} | 31 PagedArray() : pages_(NULL), page_count_(0) {} |
32 | 32 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 pages_ = NULL; | 73 pages_ = NULL; |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 private: | 77 private: |
78 T** pages_; | 78 T** pages_; |
79 size_t page_count_; | 79 size_t page_count_; |
80 | 80 |
81 DISALLOW_COPY_AND_ASSIGN(PagedArray); | 81 DISALLOW_COPY_AND_ASSIGN(PagedArray); |
82 }; | 82 }; |
83 | |
83 } // namespace | 84 } // namespace |
huangs
2016/05/13 03:56:47
NIT:
// namespace courgette
altimin
2016/05/13 13:16:57
Done.
| |
84 #endif // COURGETTE_BSDIFF_PAGED_ARRAY_H_ | 85 #endif // COURGETTE_BSDIFF_PAGED_ARRAY_H_ |
OLD | NEW |