From a70d6d79dd6c3d0b940f6f3d25d9e65e495a1129 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 14 Apr 2024 12:24:17 +1000 Subject: [PATCH] Cleanup: various non-functional C++ changes --- .../intern/mallocn_guarded_impl.cc | 28 +++++++++---------- .../intern/mallocn_lockfree_impl.cc | 20 ++++++------- .../blender/blenkernel/intern/collection.cc | 2 +- .../sculpt_paint/grease_pencil_tint.cc | 8 +++--- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.cc b/intern/guardedalloc/intern/mallocn_guarded_impl.cc index 3efeea6f039..1cf19dff208 100644 --- a/intern/guardedalloc/intern/mallocn_guarded_impl.cc +++ b/intern/guardedalloc/intern/mallocn_guarded_impl.cc @@ -97,7 +97,7 @@ static void memcount_raise(const char *name) /* --------------------------------------------------------------------- */ /* all memory chunks are put in linked lists */ typedef struct localLink { - struct localLink *next, *prev; + localLink *next, *prev; } localLink; typedef struct localListBase { @@ -108,7 +108,7 @@ typedef struct localListBase { typedef struct MemHead { int tag1; size_t len; - struct MemHead *next, *prev; + MemHead *next, *prev; const char *name; const char *nextname; int tag2; @@ -159,7 +159,7 @@ static const char *check_memlist(MemHead *memh); #ifdef __BIG_ENDIAN__ # define MAKE_ID(a, b, c, d) ((int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d)) #else -# define MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a)) +# define MAKE_ID(a, b, c, d) (int(d) << 24 | int(c) << 16 | (b) << 8 | (a)) #endif #define MEMTAG1 MAKE_ID('M', 'E', 'M', 'O') @@ -280,7 +280,7 @@ void *MEM_guarded_dupallocN(const void *vmemh) newp = MEM_guarded_mallocN(memh->len, "dupli_alloc"); } else { - newp = MEM_guarded_mallocN_aligned(memh->len, (size_t)memh->alignment, "dupli_alloc"); + newp = MEM_guarded_mallocN_aligned(memh->len, size_t(memh->alignment), "dupli_alloc"); } if (newp == nullptr) { @@ -331,7 +331,7 @@ void *MEM_guarded_reallocN_id(void *vmemh, size_t len, const char *str) newp = MEM_guarded_mallocN(len, memh->name); } else { - newp = MEM_guarded_mallocN_aligned(len, (size_t)memh->alignment, memh->name); + newp = MEM_guarded_mallocN_aligned(len, size_t(memh->alignment), memh->name); } if (newp) { @@ -366,7 +366,7 @@ void *MEM_guarded_recallocN_id(void *vmemh, size_t len, const char *str) newp = MEM_guarded_mallocN(len, memh->name); } else { - newp = MEM_guarded_mallocN_aligned(len, (size_t)memh->alignment, memh->name); + newp = MEM_guarded_mallocN_aligned(len, size_t(memh->alignment), memh->name); } if (newp) { @@ -548,7 +548,7 @@ void *MEM_guarded_mallocN_aligned(size_t len, size_t alignment, const char *str) memh = (MemHead *)((char *)memh + extra_padding); make_memhead_header(memh, len, str); - memh->alignment = (short)alignment; + memh->alignment = short(alignment); if (LIKELY(len)) { if (UNLIKELY(malloc_debug_memset)) { memset(memh + 1, 255, len); @@ -728,15 +728,15 @@ void MEM_guarded_printmemlist_stats() qsort(printblock, totpb, sizeof(MemPrintBlock), compare_len); } - printf("\ntotal memory len: %.3f MB\n", (double)mem_in_use / (double)(1024 * 1024)); - printf("peak memory len: %.3f MB\n", (double)peak_mem / (double)(1024 * 1024)); - printf("slop memory len: %.3f MB\n", (double)mem_in_use_slop / (double)(1024 * 1024)); + printf("\ntotal memory len: %.3f MB\n", double(mem_in_use) / double(1024 * 1024)); + printf("peak memory len: %.3f MB\n", double(peak_mem) / double(1024 * 1024)); + printf("slop memory len: %.3f MB\n", double(mem_in_use_slop) / double(1024 * 1024)); printf(" ITEMS TOTAL-MiB AVERAGE-KiB TYPE\n"); for (a = 0, pb = printblock; a < totpb; a++, pb++) { printf("%6d (%8.3f %8.3f) %s\n", pb->items, - (double)pb->len / (double)(1024 * 1024), - (double)pb->len / 1024.0 / (double)pb->items, + double(pb->len) / double(1024 * 1024), + double(pb->len) / 1024.0 / double(pb->items), pb->name); } @@ -913,13 +913,13 @@ void MEM_guarded_freeN(void *vmemh) } if (sizeof(intptr_t) == 8) { - if (((intptr_t)memh) & 0x7) { + if (intptr_t(memh) & 0x7) { MemorY_ErroR("free", "attempt to free illegal pointer"); return; } } else { - if (((intptr_t)memh) & 0x3) { + if (intptr_t(memh) & 0x3) { MemorY_ErroR("free", "attempt to free illegal pointer"); return; } diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.cc b/intern/guardedalloc/intern/mallocn_lockfree_impl.cc index e154c17cf6d..ba7ca885d19 100644 --- a/intern/guardedalloc/intern/mallocn_lockfree_impl.cc +++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.cc @@ -53,8 +53,8 @@ enum { #define MEMHEAD_FROM_PTR(ptr) (((MemHead *)ptr) - 1) #define PTR_FROM_MEMHEAD(memhead) (memhead + 1) #define MEMHEAD_ALIGNED_FROM_PTR(ptr) (((MemHeadAligned *)ptr) - 1) -#define MEMHEAD_IS_ALIGNED(memhead) ((memhead)->len & (size_t)MEMHEAD_ALIGN_FLAG) -#define MEMHEAD_LEN(memhead) ((memhead)->len & ~((size_t)(MEMHEAD_ALIGN_FLAG))) +#define MEMHEAD_IS_ALIGNED(memhead) ((memhead)->len & size_t(MEMHEAD_ALIGN_FLAG)) +#define MEMHEAD_LEN(memhead) ((memhead)->len & ~size_t(MEMHEAD_ALIGN_FLAG)) #ifdef __GNUC__ __attribute__((format(printf, 1, 2))) @@ -124,7 +124,7 @@ void *MEM_lockfree_dupallocN(const void *vmemh) if (UNLIKELY(MEMHEAD_IS_ALIGNED(memh))) { const MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); newp = MEM_lockfree_mallocN_aligned( - prev_size, (size_t)memh_aligned->alignment, "dupli_malloc"); + prev_size, size_t(memh_aligned->alignment), "dupli_malloc"); } else { newp = MEM_lockfree_mallocN(prev_size, "dupli_malloc"); @@ -147,7 +147,7 @@ void *MEM_lockfree_reallocN_id(void *vmemh, size_t len, const char *str) } else { const MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); - newp = MEM_lockfree_mallocN_aligned(len, (size_t)memh_aligned->alignment, "realloc"); + newp = MEM_lockfree_mallocN_aligned(len, size_t(memh_aligned->alignment), "realloc"); } if (newp) { @@ -183,7 +183,7 @@ void *MEM_lockfree_recallocN_id(void *vmemh, size_t len, const char *str) } else { const MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); - newp = MEM_lockfree_mallocN_aligned(len, (size_t)memh_aligned->alignment, "recalloc"); + newp = MEM_lockfree_mallocN_aligned(len, size_t(memh_aligned->alignment), "recalloc"); } if (newp) { @@ -358,8 +358,8 @@ void *MEM_lockfree_mallocN_aligned(size_t len, size_t alignment, const char *str #endif /* WITH_MEM_VALGRIND */ } - memh->len = len | (size_t)MEMHEAD_ALIGN_FLAG; - memh->alignment = (short)alignment; + memh->len = len | size_t(MEMHEAD_ALIGN_FLAG); + memh->alignment = short(alignment); memory_usage_block_alloc(len); return PTR_FROM_MEMHEAD(memh); @@ -385,8 +385,8 @@ void MEM_lockfree_callbackmemlist(void (*func)(void *)) void MEM_lockfree_printmemlist_stats() { - printf("\ntotal memory len: %.3f MB\n", (double)memory_usage_current() / (double)(1024 * 1024)); - printf("peak memory len: %.3f MB\n", (double)memory_usage_peak() / (double)(1024 * 1024)); + printf("\ntotal memory len: %.3f MB\n", double(memory_usage_current()) / double(1024 * 1024)); + printf("peak memory len: %.3f MB\n", double(memory_usage_peak()) / double(1024 * 1024)); printf( "\nFor more detailed per-block statistics run Blender with memory debugging command line " "argument.\n"); @@ -419,7 +419,7 @@ size_t MEM_lockfree_get_memory_in_use() uint MEM_lockfree_get_memory_blocks_in_use() { - return (uint)memory_usage_block_num(); + return uint(memory_usage_block_num()); } /* dummy */ diff --git a/source/blender/blenkernel/intern/collection.cc b/source/blender/blenkernel/intern/collection.cc index cd7eaac1c12..17743ba3731 100644 --- a/source/blender/blenkernel/intern/collection.cc +++ b/source/blender/blenkernel/intern/collection.cc @@ -514,7 +514,7 @@ void BKE_collection_free_data(Collection *collection) collection_free_data(&collection->id); } -void BKE_collection_exporter_free_data(struct CollectionExport *data) +void BKE_collection_exporter_free_data(CollectionExport *data) { if (data->export_properties) { IDP_FreeProperty(data->export_properties); diff --git a/source/blender/editors/sculpt_paint/grease_pencil_tint.cc b/source/blender/editors/sculpt_paint/grease_pencil_tint.cc index fe3f47824b7..c4a1eea212b 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_tint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_tint.cc @@ -154,10 +154,10 @@ void TintOperation::execute_tint(const bContext &C, const InputSample &extension strength = math::clamp(strength, 0.0f, 1.0f); fill_strength = math::clamp(fill_strength, 0.0f, 1.0f); - const bool tint_strokes = ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || - (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)); - const bool tint_fills = ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_FILL) || - (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)); + const bool tint_strokes = ELEM( + brush->gpencil_settings->vertex_mode, GPPAINT_MODE_STROKE, GPPAINT_MODE_BOTH); + const bool tint_fills = ELEM( + brush->gpencil_settings->vertex_mode, GPPAINT_MODE_FILL, GPPAINT_MODE_BOTH); GreasePencil &grease_pencil = *static_cast(obact->data);