OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_H | 5 #ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_H |
6 #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_H | 6 #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_H |
7 | 7 |
8 // DESCRIPTION | 8 // DESCRIPTION |
9 // partitionAlloc() / PartitionAllocGeneric() and PartitionFree() / | 9 // partitionAlloc() / PartitionAllocGeneric() and PartitionFree() / |
10 // PartitionFreeGeneric() are approximately analagous to malloc() and free(). | 10 // PartitionFreeGeneric() are approximately analagous to malloc() and free(). |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 uintptr_t masked = ByteSwapUintPtrT(reinterpret_cast<uintptr_t>(ptr)); | 500 uintptr_t masked = ByteSwapUintPtrT(reinterpret_cast<uintptr_t>(ptr)); |
501 #endif | 501 #endif |
502 return reinterpret_cast<PartitionFreelistEntry*>(masked); | 502 return reinterpret_cast<PartitionFreelistEntry*>(masked); |
503 } | 503 } |
504 | 504 |
505 ALWAYS_INLINE size_t PartitionCookieSizeAdjustAdd(size_t size) { | 505 ALWAYS_INLINE size_t PartitionCookieSizeAdjustAdd(size_t size) { |
506 #if DCHECK_IS_ON() | 506 #if DCHECK_IS_ON() |
507 // Add space for cookies, checking for integer overflow. TODO(palmer): | 507 // Add space for cookies, checking for integer overflow. TODO(palmer): |
508 // Investigate the performance and code size implications of using | 508 // Investigate the performance and code size implications of using |
509 // CheckedNumeric throughout PA. | 509 // CheckedNumeric throughout PA. |
510 DCHECK(size + (2 * kCookieSize) > size); | 510 CHECK(size + (2 * kCookieSize) > size); |
511 size += 2 * kCookieSize; | 511 size += 2 * kCookieSize; |
512 #endif | 512 #endif |
513 return size; | 513 return size; |
514 } | 514 } |
515 | 515 |
516 ALWAYS_INLINE size_t PartitionCookieSizeAdjustSubtract(size_t size) { | 516 ALWAYS_INLINE size_t PartitionCookieSizeAdjustSubtract(size_t size) { |
517 #if DCHECK_IS_ON() | 517 #if DCHECK_IS_ON() |
518 // Remove space for cookies. | 518 // Remove space for cookies. |
519 DCHECK(size >= 2 * kCookieSize); | 519 DCHECK(size >= 2 * kCookieSize); |
520 size -= 2 * kCookieSize; | 520 size -= 2 * kCookieSize; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 void init() { PartitionAllocGenericInit(&partition_root_); } | 896 void init() { PartitionAllocGenericInit(&partition_root_); } |
897 ALWAYS_INLINE PartitionRootGeneric* root() { return &partition_root_; } | 897 ALWAYS_INLINE PartitionRootGeneric* root() { return &partition_root_; } |
898 | 898 |
899 private: | 899 private: |
900 PartitionRootGeneric partition_root_; | 900 PartitionRootGeneric partition_root_; |
901 }; | 901 }; |
902 | 902 |
903 } // namespace base | 903 } // namespace base |
904 | 904 |
905 #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_H | 905 #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_H |
OLD | NEW |