From 171e77c3c25a1224fc5f7db40ec6f8879f8dbbb0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 Aug 2020 13:29:21 +1000 Subject: Cleanup: use array syntax for sizeof with fixed values Also order sizeof(..) first to promote other values to size_t. --- source/blender/draw/engines/workbench/workbench_effect_dof.c | 4 ++-- source/blender/draw/intern/draw_cache.c | 8 ++++---- source/blender/draw/intern/draw_cache_impl_displist.c | 2 +- source/blender/draw/intern/draw_fluid.c | 2 +- source/blender/draw/intern/draw_hair.c | 6 +++--- source/blender/draw/intern/draw_manager_data.c | 2 +- source/blender/draw/intern/draw_manager_exec.c | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source/blender/draw') diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c index f2f75d616ff..32f6a3392b5 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.c +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c @@ -81,10 +81,10 @@ static void workbench_dof_setup_samples(struct GPUUniformBuffer **ubo, float bokeh_ratio) { if (*data == NULL) { - *data = MEM_callocN(sizeof(float) * 4 * SAMP_LEN, "workbench dof samples"); + *data = MEM_callocN(sizeof(float[4]) * SAMP_LEN, "workbench dof samples"); } if (*ubo == NULL) { - *ubo = DRW_uniformbuffer_create(sizeof(float) * 4 * SAMP_LEN, NULL); + *ubo = DRW_uniformbuffer_create(sizeof(float[4]) * SAMP_LEN, NULL); } float *samp = *data; diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index d59c891fbeb..46b7a88b2a6 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2426,7 +2426,7 @@ static float x_axis_name[4][2] = { {-0.9f * S_X, 1.0f * S_Y}, {1.0f * S_X, -1.0f * S_Y}, }; -#define X_LEN (sizeof(x_axis_name) / (sizeof(float) * 2)) +#define X_LEN (sizeof(x_axis_name) / (sizeof(float[2]))) #undef S_X #undef S_Y @@ -2440,7 +2440,7 @@ static float y_axis_name[6][2] = { {0.0f * S_X, -0.1f * S_Y}, {0.0f * S_X, -1.0f * S_Y}, }; -#define Y_LEN (sizeof(y_axis_name) / (sizeof(float) * 2)) +#define Y_LEN (sizeof(y_axis_name) / (sizeof(float[2]))) #undef S_X #undef S_Y @@ -2458,7 +2458,7 @@ static float z_axis_name[10][2] = { {-1.00f * S_X, -1.00f * S_Y}, {1.00f * S_X, -1.00f * S_Y}, }; -#define Z_LEN (sizeof(z_axis_name) / (sizeof(float) * 2)) +#define Z_LEN (sizeof(z_axis_name) / (sizeof(float[2]))) #undef S_X #undef S_Y @@ -2485,7 +2485,7 @@ static float axis_marker[8][2] = { {-S_X, 0.f} #endif }; -#define MARKER_LEN (sizeof(axis_marker) / (sizeof(float) * 2)) +#define MARKER_LEN (sizeof(axis_marker) / (sizeof(float[2]))) #define MARKER_FILL_LAYER 6 #undef S_X #undef S_Y diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index e09f78aa51f..fb88945c5aa 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -444,7 +444,7 @@ static void displist_surf_fnors_ensure(const DispList *dl, float (**fnors)[3]) int u_len = dl->nr - ((dl->flag & DL_CYCL_U) ? 0 : 1); int v_len = dl->parts - ((dl->flag & DL_CYCL_V) ? 0 : 1); const float(*verts)[3] = (float(*)[3])dl->verts; - float(*nor_flat)[3] = MEM_mallocN(sizeof(float) * 3 * u_len * v_len, __func__); + float(*nor_flat)[3] = MEM_mallocN(sizeof(float[3]) * u_len * v_len, __func__); *fnors = nor_flat; SURFACE_QUAD_ITER_BEGIN (dl) { diff --git a/source/blender/draw/intern/draw_fluid.c b/source/blender/draw/intern/draw_fluid.c index 33311dc698f..fea379126d2 100644 --- a/source/blender/draw/intern/draw_fluid.c +++ b/source/blender/draw/intern/draw_fluid.c @@ -106,7 +106,7 @@ static void create_color_ramp(const struct ColorBand *coba, float *data) static GPUTexture *create_transfer_function(int type, const struct ColorBand *coba) { - float *data = (float *)MEM_mallocN(sizeof(float) * 4 * TFUNC_WIDTH, __func__); + float *data = (float *)MEM_mallocN(sizeof(float[4]) * TFUNC_WIDTH, __func__); switch (type) { case TFUNC_FLAME_SPECTRUM: diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index 1cbf3ee9d54..1992b1d291e 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -330,7 +330,7 @@ void DRW_hair_update(void) GPU_ATTACHMENT_TEXTURE(tex), }); - float *data = MEM_mallocN(sizeof(float) * 4 * width * height, "tf fallback buffer"); + float *data = MEM_mallocN(sizeof(float[4]) * width * height, "tf fallback buffer"); GPU_framebuffer_bind(fb); while (g_tf_calls != NULL) { @@ -347,8 +347,8 @@ void DRW_hair_update(void) /* Upload back to VBO. */ GPU_vertbuf_use(pr_call->vbo); glBufferSubData(GL_ARRAY_BUFFER, - sizeof(float) * 4 * g_tf_id_offset, - sizeof(float) * 4 * max_read_px_len, + sizeof(float[4]) * g_tf_id_offset, + sizeof(float[4]) * max_read_px_len, data); g_tf_id_offset += max_read_px_len; diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index fa68254e99a..c12b4a96488 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -1866,7 +1866,7 @@ void DRW_view_clip_planes_set(DRWView *view, float (*planes)[4], int plane_len) BLI_assert(plane_len <= MAX_CLIP_PLANES); view->clip_planes_len = plane_len; if (plane_len > 0) { - memcpy(view->storage.clipplanes, planes, sizeof(float) * 4 * plane_len); + memcpy(view->storage.clipplanes, planes, sizeof(float[4]) * plane_len); } } diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 4b63ea89e44..e3860b1bfb2 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -592,7 +592,7 @@ void DRW_culling_frustum_corners_get(const DRWView *view, BoundBox *corners) void DRW_culling_frustum_planes_get(const DRWView *view, float planes[6][4]) { view = view ? view : DST.view_default; - memcpy(planes, view->frustum_planes, sizeof(float) * 6 * 4); + memcpy(planes, view->frustum_planes, sizeof(float[6][4])); } static void draw_compute_culling(DRWView *view) -- cgit v1.2.3