Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-08-08 06:29:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-08-08 06:38:00 +0300
commit171e77c3c25a1224fc5f7db40ec6f8879f8dbbb0 (patch)
treeea51f4fa508a39807e6f6d333b2d53af8a2b9fc1 /source/blender/blenlib/intern
parent4bf3ca20165959f98c7c830a138ba2901d3dd851 (diff)
Cleanup: use array syntax for sizeof with fixed values
Also order sizeof(..) first to promote other values to size_t.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/BLI_ghash_utils.c4
-rw-r--r--source/blender/blenlib/intern/boxpack_2d.c4
-rw-r--r--source/blender/blenlib/intern/delaunay_2d.c7
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c4
-rw-r--r--source/blender/blenlib/intern/system.c2
5 files changed, 10 insertions, 11 deletions
diff --git a/source/blender/blenlib/intern/BLI_ghash_utils.c b/source/blender/blenlib/intern/BLI_ghash_utils.c
index d6a4b24682f..9323ec46d5b 100644
--- a/source/blender/blenlib/intern/BLI_ghash_utils.c
+++ b/source/blender/blenlib/intern/BLI_ghash_utils.c
@@ -55,7 +55,7 @@ uint BLI_ghashutil_ptrhash(const void *key)
/* Note: Unlike Python 'sizeof(uint)' is used instead of 'sizeof(void *)',
* Otherwise casting to 'uint' ignores the upper bits on 64bit platforms. */
- return (uint)(y >> 4) | ((uint)y << (8 * sizeof(uint) - 4));
+ return (uint)(y >> 4) | ((uint)y << (sizeof(uint[8]) - 4));
}
#endif
bool BLI_ghashutil_ptrcmp(const void *a, const void *b)
@@ -78,7 +78,7 @@ uint BLI_ghashutil_uinthash_v4(const uint key[4])
uint BLI_ghashutil_uinthash_v4_murmur(const uint key[4])
{
- return BLI_hash_mm2((const unsigned char *)key, sizeof(int) * 4 /* sizeof(key) */, 0);
+ return BLI_hash_mm2((const unsigned char *)key, sizeof(int[4]) /* sizeof(key) */, 0);
}
bool BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b)
diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c
index 5bcb0c0322a..250a3fdf21b 100644
--- a/source/blender/blenlib/intern/boxpack_2d.c
+++ b/source/blender/blenlib/intern/boxpack_2d.c
@@ -309,8 +309,8 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
qsort(boxarray, (size_t)len, sizeof(BoxPack), box_areasort);
/* add verts to the boxes, these are only used internally */
- vert = MEM_mallocN((size_t)len * 4 * sizeof(BoxVert), "BoxPack Verts");
- vertex_pack_indices = MEM_mallocN((size_t)len * 3 * sizeof(int), "BoxPack Indices");
+ vert = MEM_mallocN(sizeof(BoxVert[4]) * (size_t)len, "BoxPack Verts");
+ vertex_pack_indices = MEM_mallocN(sizeof(int[3]) * (size_t)len, "BoxPack Indices");
vs_ctx.vertarray = vert;
diff --git a/source/blender/blenlib/intern/delaunay_2d.c b/source/blender/blenlib/intern/delaunay_2d.c
index 28d9ddaef28..baf49ddaffd 100644
--- a/source/blender/blenlib/intern/delaunay_2d.c
+++ b/source/blender/blenlib/intern/delaunay_2d.c
@@ -2234,16 +2234,15 @@ static const CDT_input *modify_input_for_near_edge_ends(const CDT_input *input,
new_input->epsilon = input->epsilon;
new_input->verts_len = input->verts_len;
new_input->vert_coords = (float(*)[2])MEM_malloc_arrayN(
- new_input->verts_len, 2 * sizeof(float), __func__);
+ new_input->verts_len, sizeof(float[2]), __func__);
/* We don't do it now, but may decide to change coords of snapped verts. */
memmove(new_input->vert_coords,
input->vert_coords,
- (size_t)new_input->verts_len * sizeof(float) * 2);
+ sizeof(float[2]) * (size_t)new_input->verts_len);
if (edges_len > 0) {
new_input->edges_len = new_tot_con_edges;
- new_input->edges = (int(*)[2])MEM_malloc_arrayN(
- new_tot_con_edges, 2 * sizeof(int), __func__);
+ new_input->edges = (int(*)[2])MEM_malloc_arrayN(new_tot_con_edges, sizeof(int[2]), __func__);
}
if (input->faces_len > 0) {
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index 893c978d084..db317f5e81d 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -62,12 +62,12 @@ MINLINE float area_squared_tri_v2(const float v1[2], const float v2[2], const fl
MINLINE void zero_sh(float r[9])
{
- memset(r, 0, sizeof(float) * 9);
+ memset(r, 0, sizeof(float[9]));
}
MINLINE void copy_sh_sh(float r[9], const float a[9])
{
- memcpy(r, a, sizeof(float) * 9);
+ memcpy(r, a, sizeof(float[9]));
}
MINLINE void mul_sh_fl(float r[9], const float f)
diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
index 20edbb97561..e3572b7f05e 100644
--- a/source/blender/blenlib/intern/system.c
+++ b/source/blender/blenlib/intern/system.c
@@ -183,7 +183,7 @@ size_t BLI_system_memory_max_in_megabytes(void)
/* Maximum addressable bytes on this platform.
*
* NOTE: Due to the shift arithmetic this is a half of the memory. */
- const size_t limit_bytes_half = (((size_t)1) << ((sizeof(size_t) * 8) - 1));
+ const size_t limit_bytes_half = (((size_t)1) << ((sizeof(size_t[8])) - 1));
/* Convert it to megabytes and return. */
return (limit_bytes_half >> 20) * 2;
}