diff options
author | Jacques Lucke <jacques@blender.org> | 2022-09-25 18:39:45 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-09-25 18:39:45 +0300 |
commit | c6e70e7bacf82b38ca7125d6821713a711489c0b (patch) | |
tree | 3679590f6254b7fbbd6623080edafe217f20c7b6 /source/blender/blenlib/BLI_allocator.hh | |
parent | 0419ee871ff960f62e28a2a9fed764f66c616d71 (diff) |
Cleanup: follow C++ type cast style guide in some files
https://wiki.blender.org/wiki/Style_Guide/C_Cpp#C.2B.2B_Type_Cast
This was discussed in https://devtalk.blender.org/t/rfc-style-guide-for-type-casts-in-c-code/25907.
Diffstat (limited to 'source/blender/blenlib/BLI_allocator.hh')
-rw-r--r-- | source/blender/blenlib/BLI_allocator.hh | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_allocator.hh b/source/blender/blenlib/BLI_allocator.hh index f19292fffd8..149dda5a50e 100644 --- a/source/blender/blenlib/BLI_allocator.hh +++ b/source/blender/blenlib/BLI_allocator.hh @@ -65,13 +65,12 @@ class RawAllocator { public: void *allocate(size_t size, size_t alignment, const char *UNUSED(name)) { - BLI_assert(is_power_of_2_i(static_cast<int>(alignment))); + BLI_assert(is_power_of_2_i(int(alignment))); void *ptr = malloc(size + alignment + sizeof(MemHead)); void *used_ptr = reinterpret_cast<void *>( - reinterpret_cast<uintptr_t>(POINTER_OFFSET(ptr, alignment + sizeof(MemHead))) & - ~(static_cast<uintptr_t>(alignment) - 1)); - int offset = static_cast<int>((intptr_t)used_ptr - (intptr_t)ptr); - BLI_assert(offset >= static_cast<int>(sizeof(MemHead))); + uintptr_t(POINTER_OFFSET(ptr, alignment + sizeof(MemHead))) & ~(uintptr_t(alignment) - 1)); + int offset = int(intptr_t(used_ptr) - intptr_t(ptr)); + BLI_assert(offset >= int(sizeof(MemHead))); (static_cast<MemHead *>(used_ptr) - 1)->offset = offset; return used_ptr; } |