diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-03 15:15:05 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-03 15:16:02 +0300 |
commit | d64803f63b4311b0abb93542a907e97b47493e9f (patch) | |
tree | c9c43b768859393d1b4b1d8c0bca84081606b19a /source/blender/blenlib/BLI_linear_allocator.hh | |
parent | e797c4f28f50f2be9d6d28d4b8e5c080d53ef74f (diff) |
Cleanup: Use trailing underscore for non-public data members
This makes the code conform better with our style guide.
Diffstat (limited to 'source/blender/blenlib/BLI_linear_allocator.hh')
-rw-r--r-- | source/blender/blenlib/BLI_linear_allocator.hh | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/source/blender/blenlib/BLI_linear_allocator.hh b/source/blender/blenlib/BLI_linear_allocator.hh index 2a0dc939cb9..03264fef3bd 100644 --- a/source/blender/blenlib/BLI_linear_allocator.hh +++ b/source/blender/blenlib/BLI_linear_allocator.hh @@ -33,30 +33,30 @@ namespace blender { template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopyable, NonMovable { private: - Allocator m_allocator; - Vector<void *> m_owned_buffers; - Vector<Span<char>> m_unused_borrowed_buffers; + Allocator allocator_; + Vector<void *> owned_buffers_; + Vector<Span<char>> unused_borrowed_buffers_; - uintptr_t m_current_begin; - uintptr_t m_current_end; - uint m_next_min_alloc_size; + uintptr_t current_begin_; + uintptr_t current_end_; + uint next_min_alloc_size_; #ifdef DEBUG - uint m_debug_allocated_amount = 0; + uint debug_allocated_amount_ = 0; #endif public: LinearAllocator() { - m_current_begin = 0; - m_current_end = 0; - m_next_min_alloc_size = 64; + current_begin_ = 0; + current_end_ = 0; + next_min_alloc_size_ = 64; } ~LinearAllocator() { - for (void *ptr : m_owned_buffers) { - m_allocator.deallocate(ptr); + for (void *ptr : owned_buffers_) { + allocator_.deallocate(ptr); } } @@ -72,15 +72,15 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya BLI_assert(is_power_of_2_i(alignment)); #ifdef DEBUG - m_debug_allocated_amount += size; + debug_allocated_amount_ += size; #endif uintptr_t alignment_mask = alignment - 1; - uintptr_t potential_allocation_begin = (m_current_begin + alignment_mask) & ~alignment_mask; + uintptr_t potential_allocation_begin = (current_begin_ + alignment_mask) & ~alignment_mask; uintptr_t potential_allocation_end = potential_allocation_begin + size; - if (potential_allocation_end <= m_current_end) { - m_current_begin = potential_allocation_end; + if (potential_allocation_end <= current_end_) { + current_begin_ = potential_allocation_end; return (void *)potential_allocation_begin; } else { @@ -183,7 +183,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya */ void provide_buffer(void *buffer, uint size) { - m_unused_borrowed_buffers.append(Span<char>((char *)buffer, size)); + unused_borrowed_buffers_.append(Span<char>((char *)buffer, size)); } template<size_t Size, size_t Alignment> @@ -195,23 +195,23 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya private: void allocate_new_buffer(uint min_allocation_size) { - for (uint i : m_unused_borrowed_buffers.index_range()) { - Span<char> buffer = m_unused_borrowed_buffers[i]; + for (uint i : unused_borrowed_buffers_.index_range()) { + Span<char> buffer = unused_borrowed_buffers_[i]; if (buffer.size() >= min_allocation_size) { - m_unused_borrowed_buffers.remove_and_reorder(i); - m_current_begin = (uintptr_t)buffer.begin(); - m_current_end = (uintptr_t)buffer.end(); + unused_borrowed_buffers_.remove_and_reorder(i); + current_begin_ = (uintptr_t)buffer.begin(); + current_end_ = (uintptr_t)buffer.end(); return; } } - uint size_in_bytes = power_of_2_min_u(std::max(min_allocation_size, m_next_min_alloc_size)); - m_next_min_alloc_size = size_in_bytes * 2; + 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 = m_allocator.allocate(size_in_bytes, 8, AT); - m_owned_buffers.append(buffer); - m_current_begin = (uintptr_t)buffer; - m_current_end = m_current_begin + size_in_bytes; + void *buffer = allocator_.allocate(size_in_bytes, 8, AT); + owned_buffers_.append(buffer); + current_begin_ = (uintptr_t)buffer; + current_end_ = current_begin_ + size_in_bytes; } }; |