diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-03 15:52:51 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-03 15:53:06 +0300 |
commit | 93da09d717ff4502975c506c574faf0c07f010b4 (patch) | |
tree | 5496c001844cf557be525c08a6ef830998368d3d /source/blender/blenlib/BLI_linear_allocator.hh | |
parent | 9dce2c9d1432d2798854b909e6262fbfb94ce3c7 (diff) |
Cleanup: add const in various places
Diffstat (limited to 'source/blender/blenlib/BLI_linear_allocator.hh')
-rw-r--r-- | source/blender/blenlib/BLI_linear_allocator.hh | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_linear_allocator.hh b/source/blender/blenlib/BLI_linear_allocator.hh index 03264fef3bd..b13d88d5b93 100644 --- a/source/blender/blenlib/BLI_linear_allocator.hh +++ b/source/blender/blenlib/BLI_linear_allocator.hh @@ -66,7 +66,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya * * The alignment has to be a power of 2. */ - void *allocate(uint size, uint alignment) + void *allocate(const uint size, const uint alignment) { BLI_assert(alignment >= 1); BLI_assert(is_power_of_2_i(alignment)); @@ -75,9 +75,10 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya debug_allocated_amount_ += size; #endif - uintptr_t alignment_mask = alignment - 1; - uintptr_t potential_allocation_begin = (current_begin_ + alignment_mask) & ~alignment_mask; - uintptr_t potential_allocation_end = potential_allocation_begin + size; + const uintptr_t alignment_mask = alignment - 1; + const uintptr_t potential_allocation_begin = (current_begin_ + alignment_mask) & + ~alignment_mask; + const uintptr_t potential_allocation_end = potential_allocation_begin + size; if (potential_allocation_end <= current_end_) { current_begin_ = potential_allocation_end; @@ -140,7 +141,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya */ StringRefNull copy_string(StringRef str) { - uint alloc_size = str.size() + 1; + const uint alloc_size = str.size() + 1; char *buffer = (char *)this->allocate(alloc_size, 1); str.copy(buffer, alloc_size); return StringRefNull((const char *)buffer); @@ -205,7 +206,8 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya } } - uint size_in_bytes = power_of_2_min_u(std::max(min_allocation_size, next_min_alloc_size_)); + const uint size_in_bytes = power_of_2_min_u( + std::max(min_allocation_size, next_min_alloc_size_)); next_min_alloc_size_ = size_in_bytes * 2; void *buffer = allocator_.allocate(size_in_bytes, 8, AT); |