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/blenkernel/intern/CCGSubSurf.c | 2 +- source/blender/blenkernel/intern/DerivedMesh.c | 6 +-- source/blender/blenkernel/intern/colortools.c | 4 +- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/curve_bevel.c | 4 +- source/blender/blenkernel/intern/customdata.c | 34 +++++++-------- source/blender/blenkernel/intern/displist.c | 24 +++++------ source/blender/blenkernel/intern/dynamicpaint.c | 4 +- source/blender/blenkernel/intern/fluid.c | 16 +++---- source/blender/blenkernel/intern/gpencil_curve.c | 2 +- source/blender/blenkernel/intern/gpencil_geom.c | 6 +-- source/blender/blenkernel/intern/idprop.c | 8 ++-- source/blender/blenkernel/intern/image_gpu.c | 4 +- source/blender/blenkernel/intern/key.c | 2 +- source/blender/blenkernel/intern/lattice_deform.c | 2 +- source/blender/blenkernel/intern/mask_evaluate.c | 8 ++-- source/blender/blenkernel/intern/mask_rasterize.c | 4 +- source/blender/blenkernel/intern/mball.c | 2 +- .../blender/blenkernel/intern/mball_tessellate.c | 4 +- source/blender/blenkernel/intern/mesh_convert.c | 14 +++--- source/blender/blenkernel/intern/mesh_mirror.c | 2 +- source/blender/blenkernel/intern/multires.c | 14 +++--- .../intern/multires_reshape_apply_base.c | 4 +- .../blenkernel/intern/multires_reshape_ccg.c | 2 +- .../blenkernel/intern/multires_reshape_util.c | 2 +- .../blenkernel/intern/multires_unsubdivide.c | 6 +-- source/blender/blenkernel/intern/node.c | 4 +- source/blender/blenkernel/intern/particle.c | 4 +- .../blenkernel/intern/particle_distribute.c | 4 +- source/blender/blenkernel/intern/pbvh.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 50 +++++++++++----------- source/blender/blenkernel/intern/seqeffects.c | 26 +++++------ source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/softbody.c | 4 +- source/blender/blenkernel/intern/sound.c | 2 +- source/blender/blenkernel/intern/studiolight.c | 2 +- source/blender/blenkernel/intern/subdiv_ccg.c | 6 +-- source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- source/blender/blenkernel/intern/tracking.c | 2 +- source/blender/blenlib/intern/BLI_ghash_utils.c | 4 +- source/blender/blenlib/intern/boxpack_2d.c | 4 +- source/blender/blenlib/intern/delaunay_2d.c | 7 ++- source/blender/blenlib/intern/math_geom_inline.c | 4 +- source/blender/blenlib/intern/system.c | 2 +- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/blenloader/intern/versioning_280.c | 2 +- .../blender/blenloader/intern/versioning_legacy.c | 2 +- source/blender/blenloader/intern/writefile.c | 2 +- source/blender/bmesh/intern/bmesh_core.c | 2 +- source/blender/bmesh/intern/bmesh_interp.c | 2 +- source/blender/bmesh/intern/bmesh_mesh_convert.c | 2 +- source/blender/bmesh/intern/bmesh_operators.c | 24 +++++------ .../blender/bmesh/operators/bmo_smooth_laplacian.c | 2 +- source/blender/bmesh/tools/bmesh_bevel.c | 6 +-- .../operations/COM_CompositorOperation.cpp | 4 +- .../compositor/operations/COM_DenoiseOperation.cpp | 10 ++--- .../operations/COM_VectorBlurOperation.cpp | 4 +- .../draw/engines/workbench/workbench_effect_dof.c | 4 +- source/blender/draw/intern/draw_cache.c | 8 ++-- .../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 +- source/blender/editors/animation/anim_draw.c | 4 +- .../blender/editors/armature/armature_skinning.c | 6 +-- source/blender/editors/armature/meshlaplacian.c | 8 ++-- source/blender/editors/curve/editcurve.c | 10 ++--- source/blender/editors/curve/editcurve_add.c | 12 +++--- source/blender/editors/gpencil/gpencil_armature.c | 8 ++-- source/blender/editors/gpencil/gpencil_utils.c | 2 +- source/blender/editors/gpencil/gpencil_uv.c | 2 +- source/blender/editors/mask/mask_add.c | 4 +- source/blender/editors/mask/mask_shapekey.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 2 +- source/blender/editors/mesh/meshtools.c | 6 +-- source/blender/editors/object/object_relations.c | 2 +- source/blender/editors/physics/particle_edit.c | 2 +- source/blender/editors/render/render_opengl.c | 2 +- source/blender/editors/render/render_preview.c | 2 +- source/blender/editors/screen/glutil.c | 2 +- source/blender/editors/sculpt_paint/paint_cursor.c | 1 - .../editors/sculpt_paint/paint_image_proj.c | 8 ++-- source/blender/editors/sculpt_paint/sculpt_cloth.c | 12 +++--- .../editors/sculpt_paint/sculpt_filter_mesh.c | 4 +- .../editors/sculpt_paint/sculpt_mask_expand.c | 2 +- .../editors/sculpt_paint/sculpt_paint_color.c | 2 +- .../blender/editors/sculpt_paint/sculpt_smooth.c | 2 +- source/blender/editors/space_clip/clip_draw.c | 2 +- source/blender/editors/space_graph/graph_draw.c | 4 +- source/blender/editors/space_node/drawnode.c | 4 +- .../blender/editors/space_outliner/outliner_tree.c | 2 +- .../editors/space_sequencer/sequencer_scopes.c | 2 +- source/blender/editors/transform/transform_input.c | 2 +- .../blender/editors/uvedit/uvedit_parametrizer.c | 18 ++++---- .../blender/editors/uvedit/uvedit_smart_stitch.c | 16 +++---- .../freestyle/intern/application/AppCanvas.cpp | 5 +-- .../freestyle/intern/scene_graph/NodeCamera.cpp | 8 ++-- .../intern/view_map/SilhouetteGeomEngine.cpp | 2 +- .../gpencil_modifiers/intern/MOD_gpencilmultiply.c | 4 +- source/blender/gpu/intern/gpu_batch.cc | 2 +- source/blender/gpu/intern/gpu_buffers.c | 2 +- source/blender/gpu/intern/gpu_extensions.cc | 3 +- source/blender/gpu/intern/gpu_material.c | 2 +- source/blender/imbuf/intern/cineon/cineon_dpx.c | 4 +- source/blender/imbuf/intern/cineon/logImageCore.c | 2 +- source/blender/imbuf/intern/colormanagement.c | 4 +- source/blender/imbuf/intern/divers.c | 4 +- source/blender/imbuf/intern/jp2.c | 2 +- source/blender/imbuf/intern/moviecache.c | 2 +- .../blender/imbuf/intern/openexr/openexr_api.cpp | 2 +- source/blender/imbuf/intern/rectop.c | 2 +- source/blender/imbuf/intern/rotate.c | 6 +-- source/blender/imbuf/intern/scaling.c | 18 ++++---- source/blender/imbuf/intern/util_gpu.c | 4 +- source/blender/makesrna/intern/rna_define.c | 2 +- source/blender/makesrna/intern/rna_tracking.c | 2 +- source/blender/makesrna/intern/rna_userdef.c | 2 +- source/blender/modifiers/intern/MOD_cloth.c | 2 +- .../blender/modifiers/intern/MOD_meshcache_mdd.c | 8 ++-- .../blender/modifiers/intern/MOD_meshcache_pc2.c | 6 +-- source/blender/modifiers/intern/MOD_skin.c | 2 +- .../modifiers/intern/MOD_solidify_extrude.c | 8 ++-- source/blender/python/mathutils/mathutils_Vector.c | 6 +-- source/blender/render/intern/source/pipeline.c | 4 +- source/blender/render/intern/source/pointdensity.c | 2 +- .../blender/render/intern/source/render_result.c | 6 +-- .../blender/simulation/intern/implicit_blender.c | 2 +- 129 files changed, 344 insertions(+), 348 deletions(-) diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 396c7d4fbcc..c572b1dacf0 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1543,7 +1543,7 @@ void CCG_key(CCGKey *key, const CCGSubSurf *ss, int level) /* if normals are present, always the last three floats of an * element */ if (key->has_normals) { - key->normal_offset = key->elem_size - sizeof(float) * 3; + key->normal_offset = key->elem_size - sizeof(float[3]); } else { key->normal_offset = -1; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index af4829691c2..63e7933dd56 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -669,7 +669,7 @@ static float (*get_editbmesh_orco_verts(BMEditMesh *em))[3] /* these may not really be the orco's, but it's only for preview. * could be solver better once, but isn't simple */ - orco = MEM_malloc_arrayN(em->bm->totvert, sizeof(float) * 3, "BMEditMesh Orco"); + orco = MEM_malloc_arrayN(em->bm->totvert, sizeof(float[3]), "BMEditMesh Orco"); BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { copy_v3_v3(orco[i], eve->co); @@ -772,7 +772,7 @@ static void add_orco_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orc layerorco = CustomData_get_layer(&mesh->vdata, layer); } - memcpy(layerorco, orco, sizeof(float) * 3 * totvert); + memcpy(layerorco, orco, sizeof(float[3]) * totvert); if (free) { MEM_freeN(orco); } @@ -1371,7 +1371,7 @@ float (*editbmesh_vert_coords_alloc(BMEditMesh *em, int *r_vert_len))[3] *r_vert_len = em->bm->totvert; - cos = MEM_malloc_arrayN(em->bm->totvert, 3 * sizeof(float), "vertexcos"); + cos = MEM_malloc_arrayN(em->bm->totvert, sizeof(float[3]), "vertexcos"); BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { copy_v3_v3(cos[i], eve->co); diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 11928dada2b..116d8b1a82f 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -724,14 +724,14 @@ static void curvemap_make_table(const CurveMapping *cumap, CurveMap *cuma) bezt[a + 1].vec[1][0], point, CM_RESOL - 1, - 2 * sizeof(float)); + sizeof(float[2])); BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a + 1].vec[0][1], bezt[a + 1].vec[1][1], point + 1, CM_RESOL - 1, - 2 * sizeof(float)); + sizeof(float[2])); } /* store first and last handle for extrapolation, unit length */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 87d1b2561a9..01ce95d9d70 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -537,7 +537,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m MDeformWeight *dw = BKE_defvert_find_index(dv, defgroup); if (dw && dw->weight > 0.0f) { /* copy coordinates of point to temporary vector, then add to find average */ - memcpy(tvec, co ? co : bp->vec, 3 * sizeof(float)); + memcpy(tvec, co ? co : bp->vec, sizeof(float[3])); add_v3_v3(vec, tvec); grouped++; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 8e03f61d601..45ca89ac47e 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -725,7 +725,7 @@ float BKE_nurb_calc_length(const Nurb *nu, int resolution) bezt->vec[1][j], points + j, resolu, - 3 * sizeof(float)); + sizeof(float[3])); } prevpntsit = pntsit = points; diff --git a/source/blender/blenkernel/intern/curve_bevel.c b/source/blender/blenkernel/intern/curve_bevel.c index 7f23f0215cc..edf5b82f822 100644 --- a/source/blender/blenkernel/intern/curve_bevel.c +++ b/source/blender/blenkernel/intern/curve_bevel.c @@ -216,8 +216,8 @@ static void curve_bevel_make_from_object(Curve *cu, ListBase *disp) if (ELEM(dl->type, DL_POLY, DL_SEGM)) { DispList *dlnew = MEM_mallocN(sizeof(DispList), __func__); *dlnew = *dl; - dlnew->verts = MEM_malloc_arrayN(dl->parts * dl->nr, 3 * sizeof(float), __func__); - memcpy(dlnew->verts, dl->verts, 3 * sizeof(float) * dl->parts * dl->nr); + dlnew->verts = MEM_malloc_arrayN(dl->parts * dl->nr, sizeof(float[3]), __func__); + memcpy(dlnew->verts, dl->verts, sizeof(float[3]) * dl->parts * dl->nr); if (dlnew->type == DL_SEGM) { dlnew->flag |= (DL_FRONT_CURVE | DL_BACK_CURVE); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 0c1717ea184..f728436a759 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -597,14 +597,14 @@ static void layerSwap_mdisps(void *data, const int *ci) MEM_freeN(s->disps); s->totdisp = (s->totdisp / corners) * nverts; - s->disps = MEM_calloc_arrayN(s->totdisp, sizeof(float) * 3, "mdisp swap"); + s->disps = MEM_calloc_arrayN(s->totdisp, sizeof(float[3]), "mdisp swap"); return; } - d = MEM_calloc_arrayN(s->totdisp, 3 * sizeof(float), "mdisps swap"); + d = MEM_calloc_arrayN(s->totdisp, sizeof(float[3]), "mdisps swap"); for (S = 0; S < corners; S++) { - memcpy(d + cornersize * S, s->disps + cornersize * ci[S], cornersize * 3 * sizeof(float)); + memcpy(d + cornersize * S, s->disps + cornersize * ci[S], sizeof(float[3]) * cornersize); } MEM_freeN(s->disps); @@ -660,10 +660,10 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count) for (i = 0; i < count; i++) { if (!d[i].disps) { - d[i].disps = MEM_calloc_arrayN(d[i].totdisp, 3 * sizeof(float), "mdisps read"); + d[i].disps = MEM_calloc_arrayN(d[i].totdisp, sizeof(float[3]), "mdisps read"); } - if (!cdf_read_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) { + if (!cdf_read_data(cdf, sizeof(float[3]) * d[i].totdisp, d[i].disps)) { CLOG_ERROR(&LOG, "failed to read multires displacement %d/%d %d", i, count, d[i].totdisp); return 0; } @@ -678,7 +678,7 @@ static int layerWrite_mdisps(CDataFile *cdf, const void *data, int count) int i; for (i = 0; i < count; i++) { - if (!cdf_write_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) { + if (!cdf_write_data(cdf, sizeof(float[3]) * d[i].totdisp, d[i].disps)) { CLOG_ERROR(&LOG, "failed to write multires displacement %d/%d %d", i, count, d[i].totdisp); return 0; } @@ -694,7 +694,7 @@ static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), const void *data, int int i; for (i = 0; i < count; i++) { - size += d[i].totdisp * 3 * sizeof(float); + size += sizeof(float[3]) * d[i].totdisp; } return size; @@ -1564,7 +1564,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 0: CD_MVERT */ {sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL}, /* 1: CD_MSTICKY */ /* DEPRECATED */ - {sizeof(float) * 2, "", 1, NULL, NULL, NULL, NULL, NULL, NULL}, + {sizeof(float[2]), "", 1, NULL, NULL, NULL, NULL, NULL, NULL}, /* 2: CD_MDEFORMVERT */ {sizeof(MDeformVert), "MDeformVert", @@ -1602,7 +1602,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerMaxNum_tface}, /* 6: CD_MCOL */ /* 4 MCol structs per face */ - {sizeof(MCol) * 4, + {sizeof(MCol[4]), "MCol", 4, N_("Col"), @@ -1626,7 +1626,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, layerDefault_origindex}, /* 8: CD_NORMAL */ /* 3 floats per normal vector */ - {sizeof(float) * 3, + {sizeof(float[3]), "vec3f", 1, NULL, @@ -1677,7 +1677,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerSwap_origspace_face, layerDefault_origspace_face}, /* 14: CD_ORCO */ - {sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + {sizeof(float[3]), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, /* 15: CD_MTEXPOLY */ /* DEPRECATED */ /* note, when we expose the UV Map / TexFace split to the user, * change this back to face Texture. */ @@ -1725,7 +1725,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { NULL, layerMaxNum_mloopcol}, /* 18: CD_TANGENT */ - {sizeof(float) * 4 * 4, "", 0, N_("Tangent"), NULL, NULL, NULL, NULL, NULL}, + {sizeof(float[4][4]), "", 0, N_("Tangent"), NULL, NULL, NULL, NULL, NULL}, /* 19: CD_MDISPS */ {sizeof(MDisps), "MDisps", @@ -1747,7 +1747,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerWrite_mdisps, layerFilesize_mdisps}, /* 20: CD_PREVIEW_MCOL */ - {sizeof(MCol) * 4, + {sizeof(MCol[4]), "MCol", 4, N_("PreviewCol"), @@ -1757,9 +1757,9 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerSwap_mcol, layerDefault_mcol}, /* 21: CD_ID_MCOL */ /* DEPRECATED */ - {sizeof(MCol) * 4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + {sizeof(MCol[4]), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, /* 22: CD_TEXTURE_MCOL */ - {sizeof(MCol) * 4, + {sizeof(MCol[4]), "MCol", 4, N_("TexturedCol"), @@ -1769,7 +1769,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerSwap_mcol, layerDefault_mcol}, /* 23: CD_CLOTH_ORCO */ - {sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + {sizeof(float[3]), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, /* 24: CD_RECAST */ {sizeof(MRecast), "MRecast", 1, N_("Recast"), NULL, NULL, NULL, NULL}, @@ -1781,7 +1781,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 27: CD_SHAPE_KEYINDEX */ {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, /* 28: CD_SHAPEKEY */ - {sizeof(float) * 3, "", 0, N_("ShapeKey"), NULL, NULL, layerInterp_shapekey}, + {sizeof(float[3]), "", 0, N_("ShapeKey"), NULL, NULL, layerInterp_shapekey}, /* 29: CD_BWEIGHT */ {sizeof(float), "", 0, N_("BevelWeight"), NULL, NULL, layerInterp_bweight}, /* 30: CD_CREASE */ diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index a3e1eeb89c7..5c162486c85 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -172,7 +172,7 @@ void BKE_displist_normals_add(ListBase *lb) while (dl) { if (dl->type == DL_INDEX3) { if (dl->nors == NULL) { - dl->nors = MEM_callocN(sizeof(float) * 3, "dlnors"); + dl->nors = MEM_callocN(sizeof(float[3]), "dlnors"); if (dl->flag & DL_BACK_CURVE) { dl->nors[2] = -1.0f; @@ -184,7 +184,7 @@ void BKE_displist_normals_add(ListBase *lb) } else if (dl->type == DL_SURF) { if (dl->nors == NULL) { - dl->nors = MEM_callocN(sizeof(float) * 3 * dl->nr * dl->parts, "dlnors"); + dl->nors = MEM_callocN(sizeof(float[3]) * dl->nr * dl->parts, "dlnors"); vdata = dl->verts; ndata = dl->nors; @@ -411,7 +411,7 @@ static void curve_to_displist(Curve *cu, bezt->vec[1][j], data + j, resolu, - 3 * sizeof(float)); + sizeof(float[3])); } data += 3 * resolu; @@ -444,7 +444,7 @@ static void curve_to_displist(Curve *cu, else { dl->type = DL_SEGM; } - BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float)); + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3])); } else if (nu->type == CU_POLY) { len = nu->pntsu; @@ -571,8 +571,8 @@ void BKE_displist_fill(ListBase *dispbase, dlnew->nr = totvert; dlnew->parts = tot; - dlnew->index = MEM_mallocN(tot * 3 * sizeof(int), "dlindex"); - dlnew->verts = MEM_mallocN(totvert * 3 * sizeof(float), "dlverts"); + dlnew->index = MEM_mallocN(sizeof(int[3]) * tot, "dlindex"); + dlnew->verts = MEM_mallocN(sizeof(float[3]) * totvert, "dlverts"); /* vert data */ f1 = dlnew->verts; @@ -641,7 +641,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) if ((cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) { dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&front, dlnew); - dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); + dlnew->verts = fp1 = MEM_mallocN(sizeof(float[3]) * dl->parts, "filldisp1"); dlnew->nr = dl->parts; dlnew->parts = 1; dlnew->type = DL_POLY; @@ -662,7 +662,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) if ((cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE)) { dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&back, dlnew); - dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); + dlnew->verts = fp1 = MEM_mallocN(sizeof(float[3]) * dl->parts, "filldisp1"); dlnew->nr = dl->parts; dlnew->parts = 1; dlnew->type = DL_POLY; @@ -948,7 +948,7 @@ static float (*displist_vert_coords_alloc(ListBase *dispbase, int *r_vert_len))[ *r_vert_len += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr; } - allverts = MEM_mallocN((*r_vert_len) * sizeof(float) * 3, "displist_vert_coords_alloc allverts"); + allverts = MEM_mallocN(sizeof(float[3]) * (*r_vert_len), "displist_vert_coords_alloc allverts"); fp = (float *)allverts; for (dl = dispbase->first; dl; dl = dl->next) { int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr); @@ -1185,7 +1185,7 @@ static void displist_surf_indices(DispList *dl) dl->totindex = 0; - index = dl->index = MEM_mallocN(4 * sizeof(int) * (dl->parts + 1) * (dl->nr + 1), + index = dl->index = MEM_mallocN(sizeof(int[4]) * (dl->parts + 1) * (dl->nr + 1), "index array nurbs"); for (a = 0; a < dl->parts; a++) { @@ -1274,7 +1274,7 @@ void BKE_displist_make_surf(Depsgraph *depsgraph, dl->type = DL_SEGM; } - BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float)); + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3])); } else { len = (nu->pntsu * resolu) * (nu->pntsv * resolv); @@ -1388,7 +1388,7 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp dl = MEM_callocN(sizeof(DispList), "makeDispListbev2"); dl->verts = MEM_mallocN(sizeof(float[3]) * dlb->nr, "dlverts"); - memcpy(dl->verts, prev_fp, 3 * sizeof(float) * dlb->nr); + memcpy(dl->verts, prev_fp, sizeof(float[3]) * dlb->nr); dl->type = DL_POLY; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index a39f2ccb6d8..1c61afe5e5a 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -5166,7 +5166,7 @@ static int dynamicPaint_prepareEffectStep(struct Depsgraph *depsgraph, ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, surface->effector_weights); /* allocate memory for force data (dir vector + strength) */ - *force = MEM_mallocN(sData->total_points * 4 * sizeof(float), "PaintEffectForces"); + *force = MEM_mallocN(sizeof(float[4]) * sData->total_points, "PaintEffectForces"); if (*force) { DynamicPaintEffectData data = { @@ -6260,7 +6260,7 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph, /* calculate brush speed vectors if required */ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && brush->flags & MOD_DPAINT_DO_SMUDGE) { - bData->brush_velocity = MEM_callocN(sData->total_points * sizeof(float) * 4, + bData->brush_velocity = MEM_callocN(sizeof(float[4]) * sData->total_points, "Dynamic Paint brush velocity"); /* init adjacency data if not already */ if (!sData->adj_data) { diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index b37d940195e..eb22c2a1462 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -695,7 +695,7 @@ static void bb_allocateData(FluidObjectBB *bb, bool use_velocity, bool use_influ bb->influence = MEM_calloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_influence"); } if (use_velocity) { - bb->velocity = MEM_calloc_arrayN(bb->total_cells * 3, sizeof(float), "fluid_bb_velocity"); + bb->velocity = MEM_calloc_arrayN(bb->total_cells, sizeof(float[3]), "fluid_bb_velocity"); } bb->distances = MEM_malloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_distances"); @@ -1021,14 +1021,14 @@ static void obstacles_from_mesh(Object *coll_ob, /* TODO (sebbas): Make initialization of vertex velocities optional? */ { - vert_vel = MEM_callocN(sizeof(float) * numverts * 3, "manta_obs_velocity"); + vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_obs_velocity"); if (fes->numverts != numverts || !fes->verts_old) { if (fes->verts_old) { MEM_freeN(fes->verts_old); } - fes->verts_old = MEM_callocN(sizeof(float) * numverts * 3, "manta_obs_verts_old"); + fes->verts_old = MEM_callocN(sizeof(float[3]) * numverts, "manta_obs_verts_old"); fes->numverts = numverts; } else { @@ -1578,9 +1578,9 @@ static void emit_from_particles(Object *flow_ob, totchild = psys->totchild * psys->part->disp / 100; } - particle_pos = MEM_callocN(sizeof(float) * (totpart + totchild) * 3, + particle_pos = MEM_callocN(sizeof(float[3]) * (totpart + totchild), "manta_flow_particles_pos"); - particle_vel = MEM_callocN(sizeof(float) * (totpart + totchild) * 3, + particle_vel = MEM_callocN(sizeof(float[3]) * (totpart + totchild), "manta_flow_particles_vel"); /* setup particle radius emission if enabled */ @@ -2101,13 +2101,13 @@ static void emit_from_mesh( mloopuv = CustomData_get_layer_named(&me->ldata, CD_MLOOPUV, ffs->uvlayer_name); if (ffs->flags & FLUID_FLOW_INITVELOCITY) { - vert_vel = MEM_callocN(sizeof(float) * numverts * 3, "manta_flow_velocity"); + vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_velocity"); if (ffs->numverts != numverts || !ffs->verts_old) { if (ffs->verts_old) { MEM_freeN(ffs->verts_old); } - ffs->verts_old = MEM_callocN(sizeof(float) * numverts * 3, "manta_flow_verts_old"); + ffs->verts_old = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_verts_old"); ffs->numverts = numverts; } else { @@ -3331,7 +3331,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds, Mesh *orgmesh, Obj co_offset[2] = (fds->p0[2] + fds->p1[2]) / 2.0f; /* Normals. */ - normals = MEM_callocN(sizeof(short) * num_normals * 3, "Fluidmesh_tmp_normals"); + normals = MEM_callocN(sizeof(short[3]) * num_normals, "Fluidmesh_tmp_normals"); /* Loop for vertices and normals. */ for (i = 0, no_s = normals; i < num_verts && i < num_normals; i++, mverts++, no_s += 3) { diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 3e568bd5e1e..e64369d74cb 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -329,7 +329,7 @@ static void gpencil_convert_spline(Main *bmain, bezt->vec[1][j], coord_array + j, resolu - 1, - 3 * sizeof(float)); + sizeof(float[3])); } /* Save first point coordinates. */ if (s == 0) { diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 672d65f1585..65ce117431b 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -237,7 +237,7 @@ static int stroke_march_next_point(const bGPDstroke *gps, copy_v3_v3(result, &pt->x); *pressure = gps->points[next_point_index].pressure; *strength = gps->points[next_point_index].strength; - memcpy(vert_color, gps->points[next_point_index].vert_color, sizeof(float) * 4); + memcpy(vert_color, gps->points[next_point_index].vert_color, sizeof(float[4])); *index_from = next_point_index - 1; *index_to = next_point_index; @@ -445,7 +445,7 @@ bool BKE_gpencil_stroke_sample(bGPDstroke *gps, const float dist, const bool sel copy_v3_v3(&pt2->x, last_coord); new_pt[i].pressure = pt[0].pressure; new_pt[i].strength = pt[0].strength; - memcpy(new_pt[i].vert_color, pt[0].vert_color, sizeof(float) * 4); + memcpy(new_pt[i].vert_color, pt[0].vert_color, sizeof(float[4])); if (select) { new_pt[i].flag |= GP_SPOINT_SELECT; } @@ -471,7 +471,7 @@ bool BKE_gpencil_stroke_sample(bGPDstroke *gps, const float dist, const bool sel copy_v3_v3(&pt2->x, last_coord); new_pt[i].pressure = pressure; new_pt[i].strength = strength; - memcpy(new_pt[i].vert_color, vert_color, sizeof(float) * 4); + memcpy(new_pt[i].vert_color, vert_color, sizeof(float[4])); if (select) { new_pt[i].flag |= GP_SPOINT_SELECT; } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index e394242001c..529ae227df9 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -55,10 +55,10 @@ static size_t idp_size_table[] = { 1, /*strings*/ sizeof(int), sizeof(float), - sizeof(float) * 3, /*Vector type, deprecated*/ - sizeof(float) * 16, /*Matrix type, deprecated*/ - 0, /*arrays don't have a fixed size*/ - sizeof(ListBase), /*Group type*/ + sizeof(float[3]), /*Vector type, deprecated*/ + sizeof(float[16]), /*Matrix type, deprecated*/ + 0, /*arrays don't have a fixed size*/ + sizeof(ListBase), /*Group type*/ sizeof(void *), sizeof(double), }; diff --git a/source/blender/blenkernel/intern/image_gpu.c b/source/blender/blenkernel/intern/image_gpu.c index 22fb6dfd02a..78a705ae145 100644 --- a/source/blender/blenkernel/intern/image_gpu.c +++ b/source/blender/blenkernel/intern/image_gpu.c @@ -633,7 +633,7 @@ static void gpu_texture_update_from_ibuf( const bool compress_as_srgb = !IMB_colormanagement_space_is_scene_linear( ibuf->rect_colorspace); - rect = (uchar *)MEM_mallocN(sizeof(uchar) * 4 * w * h, __func__); + rect = (uchar *)MEM_mallocN(sizeof(uchar[4]) * w * h, __func__); if (rect == NULL) { return; } @@ -653,7 +653,7 @@ static void gpu_texture_update_from_ibuf( const bool store_premultiplied = (ima->alpha_mode != IMA_ALPHA_STRAIGHT); if (ibuf->channels != 4 || scaled || !store_premultiplied) { - rect_float = (float *)MEM_mallocN(sizeof(float) * 4 * w * h, __func__); + rect_float = (float *)MEM_mallocN(sizeof(float[4]) * w * h, __func__); if (rect_float == NULL) { return; } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index a71b9cc2a1d..0108befa710 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -569,7 +569,7 @@ static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char ** if (me->edit_mesh && me->edit_mesh->bm->totvert == kb->totelem) { a = 0; - co = MEM_mallocN(sizeof(float) * 3 * me->edit_mesh->bm->totvert, "key_block_get_data"); + co = MEM_mallocN(sizeof(float[3]) * me->edit_mesh->bm->totvert, "key_block_get_data"); BM_ITER_MESH (eve, &iter, me->edit_mesh->bm, BM_VERTS_OF_MESH) { copy_v3_v3(co[a], eve->co); diff --git a/source/blender/blenkernel/intern/lattice_deform.c b/source/blender/blenkernel/intern/lattice_deform.c index 674ee9ed2c5..33f7d9851db 100644 --- a/source/blender/blenkernel/intern/lattice_deform.c +++ b/source/blender/blenkernel/intern/lattice_deform.c @@ -80,7 +80,7 @@ LatticeDeformData *BKE_lattice_deform_data_create(const Object *oblatt, const Ob } bp = lt->def; - fp = latticedata = MEM_mallocN(sizeof(float) * 3 * lt->pntsu * lt->pntsv * lt->pntsw, + fp = latticedata = MEM_mallocN(sizeof(float[3]) * lt->pntsu * lt->pntsv * lt->pntsw, "latticedata"); /* for example with a particle system: (ob == NULL) */ diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c index d0f80bf92b9..2fbf5f8648d 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.c +++ b/source/blender/blenkernel/intern/mask_evaluate.c @@ -178,7 +178,7 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, bezt_curr->vec[1][j], &(*fp)[j], resol, - 2 * sizeof(float)); + sizeof(float[2])); } fp += resol; @@ -687,7 +687,7 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__double bezt_curr->vec[1][j], &(*fp)[j], resol, - 2 * sizeof(float)); + sizeof(float[2])); } /* scale by the uw's */ @@ -845,7 +845,7 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline, /* resol+1 because of 'forward_diff_bezier' function */ *tot_diff_point = resol + 1; - diff_points = fp = MEM_callocN((resol + 1) * 2 * sizeof(float), "mask segment vets"); + diff_points = fp = MEM_callocN(sizeof(float[2]) * (resol + 1), "mask segment vets"); for (j = 0; j < 2; j++) { BKE_curve_forward_diff_bezier(bezt->vec[1][j], @@ -854,7 +854,7 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline, bezt_next->vec[1][j], fp + j, resol, - 2 * sizeof(float)); + sizeof(float[2])); } copy_v2_v2(fp + 2 * resol, bezt_next->vec[1]); diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index b28cd9c6c8e..92885535f57 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -786,7 +786,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, co_feather[2] = 1.0f; if (spline->flag & MASK_SPLINE_NOINTERSECT) { - diff_feather_points_flip = MEM_mallocN(sizeof(float) * 2 * tot_diff_feather_points, + diff_feather_points_flip = MEM_mallocN(sizeof(float[2]) * tot_diff_feather_points, "diff_feather_points_flip"); for (j = 0; j < tot_diff_point; j++) { @@ -939,7 +939,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, ListBase isect_remedgebase = {NULL, NULL}; /* now we have all the splines */ - face_coords = MEM_mallocN((sizeof(float) * 3) * sf_vert_tot, "maskrast_face_coords"); + face_coords = MEM_mallocN((sizeof(float[3])) * sf_vert_tot, "maskrast_face_coords"); /* init bounds */ BLI_rctf_init_minmax(&bounds); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 3a514608c77..de07c96e3f0 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -281,7 +281,7 @@ float *BKE_mball_make_orco(Object *ob, ListBase *dispbase) size[2] = bb->vec[1][2] - loc[2]; dl = dispbase->first; - orcodata = MEM_mallocN(sizeof(float) * 3 * dl->nr, "MballOrco"); + orcodata = MEM_mallocN(sizeof(float[3]) * dl->nr, "MballOrco"); data = dl->verts; orco = orcodata; diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c index 72b99bea0f4..92e16be878f 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.c +++ b/source/blender/blenkernel/intern/mball_tessellate.c @@ -1276,8 +1276,8 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje new_ml = BLI_memarena_alloc(process->pgn_elements, sizeof(MetaElem)); *(new_ml) = *ml; new_ml->bb = BLI_memarena_alloc(process->pgn_elements, sizeof(BoundBox)); - new_ml->mat = BLI_memarena_alloc(process->pgn_elements, 4 * 4 * sizeof(float)); - new_ml->imat = BLI_memarena_alloc(process->pgn_elements, 4 * 4 * sizeof(float)); + new_ml->mat = BLI_memarena_alloc(process->pgn_elements, sizeof(float[4][4])); + new_ml->imat = BLI_memarena_alloc(process->pgn_elements, sizeof(float[4][4])); /* too big stiffness seems only ugly due to linear interpolation * no need to have possibility for too big stiffness */ diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index a0f3bc9e74d..76a6d23bc8f 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -314,11 +314,11 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, *r_allvert = mvert = MEM_calloc_arrayN(totvert, sizeof(MVert), "nurbs_init mvert"); *r_alledge = medge = MEM_calloc_arrayN(totedge, sizeof(MEdge), "nurbs_init medge"); *r_allloop = mloop = MEM_calloc_arrayN( - totpoly, 4 * sizeof(MLoop), "nurbs_init mloop"); // totloop + totpoly, sizeof(MLoop[4]), "nurbs_init mloop"); // totloop *r_allpoly = mpoly = MEM_calloc_arrayN(totpoly, sizeof(MPoly), "nurbs_init mloop"); if (r_alluv) { - *r_alluv = mloopuv = MEM_calloc_arrayN(totpoly, 4 * sizeof(MLoopUV), "nurbs_init mloopuv"); + *r_alluv = mloopuv = MEM_calloc_arrayN(totpoly, sizeof(MLoopUV[4]), "nurbs_init mloopuv"); } /* verts and faces */ @@ -1298,11 +1298,11 @@ static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src) mesh_src->totvert, kb->name, kb->totelem); - array = MEM_calloc_arrayN((size_t)mesh_src->totvert, 3 * sizeof(float), __func__); + array = MEM_calloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__); } else { - array = MEM_malloc_arrayN((size_t)mesh_src->totvert, 3 * sizeof(float), __func__); - memcpy(array, kb->data, (size_t)mesh_src->totvert * 3 * sizeof(float)); + array = MEM_malloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__); + memcpy(array, kb->data, sizeof(float[3]) * (size_t)mesh_src->totvert); } CustomData_add_layer_named( @@ -1405,7 +1405,7 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act cos = CustomData_get_layer_n(&mesh_src->vdata, CD_SHAPEKEY, i); kb->totelem = mesh_src->totvert; - kb->data = kbcos = MEM_malloc_arrayN(kb->totelem, 3 * sizeof(float), __func__); + kb->data = kbcos = MEM_malloc_arrayN(kb->totelem, sizeof(float[3]), __func__); if (kb->uid == actshape_uid) { MVert *mvert = mesh_src->mvert; @@ -1427,7 +1427,7 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act } kb->totelem = mesh_src->totvert; - kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), __func__); + kb->data = MEM_calloc_arrayN(kb->totelem, sizeof(float[3]), __func__); CLOG_ERROR(&LOG, "lost a shapekey layer: '%s'! (bmesh internal error)", kb->name); } } diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c index d9be9a99b2b..46764a56e60 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.c +++ b/source/blender/blenkernel/intern/mesh_mirror.c @@ -197,7 +197,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis(MirrorModifierData *mmd, if (do_vtargetmap) { /* second half is filled with -1 */ - vtargetmap = MEM_malloc_arrayN(maxVerts, 2 * sizeof(int), "MOD_mirror tarmap"); + vtargetmap = MEM_malloc_arrayN(maxVerts, sizeof(int[2]), "MOD_mirror tarmap"); vtmap_a = vtargetmap; vtmap_b = vtargetmap + maxVerts; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 392f95af917..6e1168d8a16 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -608,7 +608,7 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl) /* reallocate displacements to be filled in */ for (i = 0; i < totloop; i++) { int totdisp = multires_grid_tot[lvl]; - float(*disps)[3] = MEM_calloc_arrayN(totdisp, 3 * sizeof(float), "multires disps"); + float(*disps)[3] = MEM_calloc_arrayN(totdisp, sizeof(float[3]), "multires disps"); if (mdisps[i].disps) { MEM_freeN(mdisps[i].disps); @@ -726,7 +726,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) float(*disps)[3], (*ndisps)[3], (*hdisps)[3]; int totdisp = multires_grid_tot[lvl]; - disps = MEM_calloc_arrayN(totdisp, 3 * sizeof(float), "multires disps"); + disps = MEM_calloc_arrayN(totdisp, sizeof(float[3]), "multires disps"); if (mdisp->disps != NULL) { ndisps = disps; @@ -1540,7 +1540,7 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp) int x, y, S; float(*disps)[3], (*out)[3], u = 0.0f, v = 0.0f; /* Quite gcc barking. */ - disps = MEM_calloc_arrayN(newtotdisp, 3 * sizeof(float), "multires disps"); + disps = MEM_calloc_arrayN(newtotdisp, sizeof(float[3]), "multires disps"); out = disps; for (S = 0; S < nvert; S++) { @@ -1600,7 +1600,7 @@ void multires_load_old_250(Mesh *me) for (j = 0; j < nvert; j++, k++) { mdisps2[k].disps = MEM_calloc_arrayN( - totdisp, 3 * sizeof(float), "multires disp in conversion"); + totdisp, sizeof(float[3]), "multires disp in conversion"); mdisps2[k].totdisp = totdisp; mdisps2[k].level = mdisps[i].level; memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp * j, totdisp); @@ -1672,7 +1672,7 @@ static void create_old_vert_face_map(ListBase **map, IndexNode *node = NULL; (*map) = MEM_calloc_arrayN(totvert, sizeof(ListBase), "vert face map"); - (*mem) = MEM_calloc_arrayN(totface, 4 * sizeof(IndexNode), "vert face map mem"); + (*mem) = MEM_calloc_arrayN(totface, sizeof(IndexNode[4]), "vert face map mem"); node = *mem; /* Find the users */ @@ -1694,7 +1694,7 @@ static void create_old_vert_edge_map(ListBase **map, IndexNode *node = NULL; (*map) = MEM_calloc_arrayN(totvert, sizeof(ListBase), "vert edge map"); - (*mem) = MEM_calloc_arrayN(totedge, 2 * sizeof(IndexNode), "vert edge map mem"); + (*mem) = MEM_calloc_arrayN(totedge, sizeof(IndexNode[2]), "vert edge map mem"); node = *mem; /* Find the users */ @@ -2376,7 +2376,7 @@ void multires_topology_changed(Mesh *me) if (!mdisp->totdisp || !mdisp->disps) { if (grid) { mdisp->totdisp = grid; - mdisp->disps = MEM_calloc_arrayN(3 * sizeof(float), mdisp->totdisp, "mdisp topology"); + mdisp->disps = MEM_calloc_arrayN(sizeof(float[3]), mdisp->totdisp, "mdisp topology"); } continue; diff --git a/source/blender/blenkernel/intern/multires_reshape_apply_base.c b/source/blender/blenkernel/intern/multires_reshape_apply_base.c index 10a43a4c9b8..6e7e2b90c05 100644 --- a/source/blender/blenkernel/intern/multires_reshape_apply_base.c +++ b/source/blender/blenkernel/intern/multires_reshape_apply_base.c @@ -99,7 +99,7 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape base_mesh->totloop); float(*origco)[3] = MEM_calloc_arrayN( - base_mesh->totvert, 3 * sizeof(float), "multires apply base origco"); + base_mesh->totvert, sizeof(float[3]), "multires apply base origco"); for (int i = 0; i < base_mesh->totvert; i++) { copy_v3_v3(origco[i], base_mesh->mvert[i].co); } @@ -140,7 +140,7 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape fake_poly.totloop = p->totloop; fake_poly.loopstart = 0; fake_loops = MEM_malloc_arrayN(p->totloop, sizeof(MLoop), "fake_loops"); - fake_co = MEM_malloc_arrayN(p->totloop, 3 * sizeof(float), "fake_co"); + fake_co = MEM_malloc_arrayN(p->totloop, sizeof(float[3]), "fake_co"); for (int k = 0; k < p->totloop; k++) { const int vndx = base_mesh->mloop[p->loopstart + k].v; diff --git a/source/blender/blenkernel/intern/multires_reshape_ccg.c b/source/blender/blenkernel/intern/multires_reshape_ccg.c index 8273845e820..55f7766c878 100644 --- a/source/blender/blenkernel/intern/multires_reshape_ccg.c +++ b/source/blender/blenkernel/intern/multires_reshape_ccg.c @@ -58,7 +58,7 @@ bool multires_reshape_assign_final_coords_from_ccg(const MultiresReshapeContext BLI_assert(grid_element.displacement != NULL); memcpy(grid_element.displacement, CCG_grid_elem_co(&reshape_level_key, ccg_grid, x, y), - sizeof(float) * 3); + sizeof(float[3])); if (reshape_level_key.has_mask) { BLI_assert(grid_element.mask != NULL); diff --git a/source/blender/blenkernel/intern/multires_reshape_util.c b/source/blender/blenkernel/intern/multires_reshape_util.c index e9a779dafeb..c8179dd8a2d 100644 --- a/source/blender/blenkernel/intern/multires_reshape_util.c +++ b/source/blender/blenkernel/intern/multires_reshape_util.c @@ -522,7 +522,7 @@ static void allocate_displacement_grid(MDisps *displacement_grid, const int leve { const int grid_size = BKE_subdiv_grid_size_from_level(level); const int grid_area = grid_size * grid_size; - float(*disps)[3] = MEM_calloc_arrayN(grid_area, 3 * sizeof(float), "multires disps"); + float(*disps)[3] = MEM_calloc_arrayN(grid_area, sizeof(float[3]), "multires disps"); if (displacement_grid->disps != NULL) { MEM_freeN(displacement_grid->disps); } diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c b/source/blender/blenkernel/intern/multires_unsubdivide.c index c9bb9518230..e3d670f7c39 100644 --- a/source/blender/blenkernel/intern/multires_unsubdivide.c +++ b/source/blender/blenkernel/intern/multires_unsubdivide.c @@ -677,7 +677,7 @@ static void store_grid_data(MultiresUnsubdivideContext *context, const int grid_size = BKE_ccg_gridsize(context->num_original_levels); const int face_grid_size = BKE_ccg_gridsize(context->num_original_levels + 1); const int face_grid_area = face_grid_size * face_grid_size; - float(*face_grid)[3] = MEM_calloc_arrayN(face_grid_area, 3 * sizeof(float), "face_grid"); + float(*face_grid)[3] = MEM_calloc_arrayN(face_grid_area, sizeof(float[3]), "face_grid"); for (int i = 0; i < poly->totloop; i++) { const int loop_index = poly->loopstart + i; @@ -731,7 +731,7 @@ static void multires_unsubdivide_extract_single_grid_from_face_edge( const int unsubdiv_grid_size = grid->grid_size = BKE_ccg_gridsize(context->num_total_levels); grid->grid_size = unsubdiv_grid_size; grid->grid_co = MEM_calloc_arrayN( - unsubdiv_grid_size * unsubdiv_grid_size, 3 * sizeof(float), "grids coordinates"); + unsubdiv_grid_size * unsubdiv_grid_size, sizeof(float[3]), "grids coordinates"); /* Get the vertex on the corner of the grid. This vertex was tagged previously as it also exist * on the base mesh. */ @@ -1198,7 +1198,7 @@ static void multires_create_grids_in_unsubdivided_base_mesh(MultiresUnsubdivideC /* Allocate the MDISPS grids and copy the extracted data from context. */ for (int i = 0; i < totloop; i++) { - float(*disps)[3] = MEM_calloc_arrayN(totdisp, 3 * sizeof(float), "multires disps"); + float(*disps)[3] = MEM_calloc_arrayN(totdisp, sizeof(float[3]), "multires disps"); if (mdisps[i].disps) { MEM_freeN(mdisps[i].disps); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index d77e7cf862d..a89285a28c1 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1917,7 +1917,7 @@ bNodePreview *BKE_node_preview_verify( } if (preview->rect == NULL) { - preview->rect = MEM_callocN(4 * xsize + xsize * ysize * sizeof(char) * 4, "node preview rect"); + preview->rect = MEM_callocN(4 * xsize + xsize * ysize * sizeof(char[4]), "node preview rect"); preview->xsize = xsize; preview->ysize = ysize; } @@ -2055,7 +2055,7 @@ static void node_preview_sync(bNodePreview *to, bNodePreview *from) if (to->rect && from->rect) { int xsize = to->xsize; int ysize = to->ysize; - memcpy(to->rect, from->rect, xsize * ysize * sizeof(char) * 4); + memcpy(to->rect, from->rect, xsize * ysize * sizeof(char[4])); } } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 363706ca969..b3da6c53b34 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3480,7 +3480,7 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat { float det, w1, w2, d1[2], d2[2]; - memset(mat, 0, sizeof(float) * 4 * 4); + memset(mat, 0, sizeof(float[4][4])); mat[3][3] = 1.0f; /* first axis is the normal */ @@ -4385,7 +4385,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, short cpa_from; /* initialize keys to zero */ - memset(keys, 0, 4 * sizeof(ParticleKey)); + memset(keys, 0, sizeof(ParticleKey[4])); t = state->time; CLAMP(t, 0.0f, 1.0f); diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c index dc6d5e974ed..fad93245a04 100644 --- a/source/blender/blenkernel/intern/particle_distribute.c +++ b/source/blender/blenkernel/intern/particle_distribute.c @@ -382,7 +382,7 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount) x -= (float)floor(x); } - jit2 = MEM_mallocN(12 + 2 * sizeof(float) * num, "initjit"); + jit2 = MEM_mallocN(12 + sizeof(float[2]) * num, "initjit"); for (i = 0; i < 4; i++) { BLI_jitterate1((float(*)[2])jit, (float(*)[2])jit2, num, rad1); @@ -1280,7 +1280,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, hammersley_create(jit, jitlevel + 1, psys->seed, part->jitfac); } BLI_array_randomize( - jit, 2 * sizeof(float), jitlevel, psys->seed); /* for custom jit or even distribution */ + jit, sizeof(float[2]), jitlevel, psys->seed); /* for custom jit or even distribution */ } /* Setup things for threaded distribution */ diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 1dd22a0a28d..1e4ea19adb6 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2912,7 +2912,7 @@ PBVHColorBufferNode *BKE_pbvh_node_color_buffer_get(PBVHNode *node) { if (!node->color_buffer.color) { - node->color_buffer.color = MEM_callocN(node->uniq_verts * sizeof(float) * 4, "Color buffer"); + node->color_buffer.color = MEM_callocN(sizeof(float[4]) * node->uniq_verts, "Color buffer"); } return &node->color_buffer; } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index ae18f3289e4..64e642462af 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -126,19 +126,19 @@ static CLG_LogRef LOG = {"bke.pointcache"}; static int ptcache_data_size[] = { sizeof(unsigned int), // BPHYS_DATA_INDEX - 3 * sizeof(float), // BPHYS_DATA_LOCATION - 3 * sizeof(float), // BPHYS_DATA_VELOCITY - 4 * sizeof(float), // BPHYS_DATA_ROTATION - 3 * sizeof(float), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST + sizeof(float[3]), // BPHYS_DATA_LOCATION + sizeof(float[3]), // BPHYS_DATA_VELOCITY + sizeof(float[4]), // BPHYS_DATA_ROTATION + sizeof(float[3]), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST sizeof(float), // BPHYS_DATA_SIZE - 3 * sizeof(float), // BPHYS_DATA_TIMES + sizeof(float[3]), // BPHYS_DATA_TIMES sizeof(BoidData), // case BPHYS_DATA_BOIDS }; static int ptcache_extra_datasize[] = { 0, sizeof(ParticleSpring), - sizeof(float) * 3, + sizeof(float[3]), }; /* forward declarations */ @@ -212,8 +212,8 @@ static void ptcache_softbody_read( BodyPoint *bp = soft->bpoint + index; if (old_data) { - memcpy(bp->pos, data, 3 * sizeof(float)); - memcpy(bp->vec, data + 3, 3 * sizeof(float)); + memcpy(bp->pos, data, sizeof(float[3])); + memcpy(bp->vec, data + 3, sizeof(float[3])); } else { PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, bp->pos); @@ -241,8 +241,8 @@ static void ptcache_softbody_interpolate(int index, copy_v3_v3(keys[1].vel, bp->vec); if (old_data) { - memcpy(keys[2].co, old_data, 3 * sizeof(float)); - memcpy(keys[2].vel, old_data + 3, 3 * sizeof(float)); + memcpy(keys[2].co, old_data, sizeof(float[3])); + memcpy(keys[2].vel, old_data + 3, sizeof(float[3])); } else { BKE_ptcache_make_particle_key(keys + 2, 0, data, cfra2); @@ -545,9 +545,9 @@ static void ptcache_cloth_read( ClothVertex *vert = cloth->verts + index; if (old_data) { - memcpy(vert->x, data, 3 * sizeof(float)); - memcpy(vert->xconst, data + 3, 3 * sizeof(float)); - memcpy(vert->v, data + 6, 3 * sizeof(float)); + memcpy(vert->x, data, sizeof(float[3])); + memcpy(vert->xconst, data + 3, sizeof(float[3])); + memcpy(vert->v, data + 6, sizeof(float[3])); } else { PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, vert->x); @@ -577,8 +577,8 @@ static void ptcache_cloth_interpolate(int index, copy_v3_v3(keys[1].vel, vert->v); if (old_data) { - memcpy(keys[2].co, old_data, 3 * sizeof(float)); - memcpy(keys[2].vel, old_data + 6, 3 * sizeof(float)); + memcpy(keys[2].co, old_data, sizeof(float[3])); + memcpy(keys[2].vel, old_data + 6, sizeof(float[3])); } else { BKE_ptcache_make_particle_key(keys + 2, 0, data, cfra2); @@ -1421,7 +1421,7 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v) int cache_compress = 1; /* version header */ - ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char) * 4); + ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char[4])); if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) { int total_points = surface->data->total_points; @@ -1459,7 +1459,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) char version[4]; /* version header */ - ptcache_file_read(pf, version, 1, sizeof(char) * 4); + ptcache_file_read(pf, version, 1, sizeof(char[4])); if (!STREQLEN(version, DPAINT_CACHE_VERSION, 4)) { CLOG_ERROR(&LOG, "Dynamic Paint: Invalid cache version: '%c%c%c%c'!", UNPACK4(version)); return 0; @@ -1538,8 +1538,8 @@ static void ptcache_rigidbody_read( if (rbo->type == RBO_TYPE_ACTIVE) { if (old_data) { - memcpy(rbo->pos, data, 3 * sizeof(float)); - memcpy(rbo->orn, data + 3, 4 * sizeof(float)); + memcpy(rbo->pos, data, sizeof(float[3])); + memcpy(rbo->orn, data + 3, sizeof(float[4])); } else { PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, rbo->pos); @@ -1577,8 +1577,8 @@ static void ptcache_rigidbody_interpolate(int index, copy_qt_qt(keys[1].rot, rbo->orn); if (old_data) { - memcpy(keys[2].co, data, 3 * sizeof(float)); - memcpy(keys[2].rot, data + 3, 4 * sizeof(float)); + memcpy(keys[2].co, data, sizeof(float[3])); + memcpy(keys[2].rot, data + 3, sizeof(float[4])); } else { BKE_ptcache_make_particle_key(&keys[2], 0, data, cfra2); @@ -2276,7 +2276,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, size_t out_len = len; #endif unsigned char *in; - unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp"); + unsigned char *props = MEM_callocN(sizeof(char[16]), "tmp"); ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); if (compressed) { @@ -2322,7 +2322,7 @@ static int ptcache_file_compressed_write( int r = 0; unsigned char compressed = 0; size_t out_len = 0; - unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp"); + unsigned char *props = MEM_callocN(sizeof(char[16]), "tmp"); size_t sizeOfIt = 5; (void)mode; /* unused when building w/o compression */ @@ -2623,13 +2623,13 @@ static void ptcache_mem_clear(PTCacheMem *pm) static int ptcache_old_elemsize(PTCacheID *pid) { if (pid->type == PTCACHE_TYPE_SOFTBODY) { - return 6 * sizeof(float); + return sizeof(float[6]); } if (pid->type == PTCACHE_TYPE_PARTICLES) { return sizeof(ParticleKey); } if (pid->type == PTCACHE_TYPE_CLOTH) { - return 9 * sizeof(float); + return sizeof(float[9]); } return 0; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 55de375ce1e..afec9b835a5 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -303,10 +303,10 @@ static void do_alphaover_effect_float( mfac = 1.0f - (fac2 * rt1[3]); if (fac <= 0.0f) { - memcpy(rt, rt2, 4 * sizeof(float)); + memcpy(rt, rt2, sizeof(float[4])); } else if (mfac <= 0) { - memcpy(rt, rt1, 4 * sizeof(float)); + memcpy(rt, rt1, sizeof(float[4])); } else { rt[0] = fac * rt1[0] + mfac * rt2[0]; @@ -330,10 +330,10 @@ static void do_alphaover_effect_float( mfac = 1.0f - (fac4 * rt1[3]); if (fac <= 0.0f) { - memcpy(rt, rt2, 4 * sizeof(float)); + memcpy(rt, rt2, sizeof(float[4])); } else if (mfac <= 0.0f) { - memcpy(rt, rt1, 4 * sizeof(float)); + memcpy(rt, rt1, sizeof(float[4])); } else { rt[0] = fac * rt1[0] + mfac * rt2[0]; @@ -499,16 +499,16 @@ static void do_alphaunder_effect_float( * 'skybuf' can be crossed in */ if (rt2[3] <= 0 && fac2 >= 1.0f) { - memcpy(rt, rt1, 4 * sizeof(float)); + memcpy(rt, rt1, sizeof(float[4])); } else if (rt2[3] >= 1.0f) { - memcpy(rt, rt2, 4 * sizeof(float)); + memcpy(rt, rt2, sizeof(float[4])); } else { fac = fac2 * (1.0f - rt2[3]); if (fac == 0) { - memcpy(rt, rt2, 4 * sizeof(float)); + memcpy(rt, rt2, sizeof(float[4])); } else { rt[0] = fac * rt1[0] + rt2[0]; @@ -530,16 +530,16 @@ static void do_alphaunder_effect_float( x = xo; while (x--) { if (rt2[3] <= 0 && fac4 >= 1.0f) { - memcpy(rt, rt1, 4 * sizeof(float)); + memcpy(rt, rt1, sizeof(float[4])); } else if (rt2[3] >= 1.0f) { - memcpy(rt, rt2, 4 * sizeof(float)); + memcpy(rt, rt2, sizeof(float[4])); } else { fac = fac4 * (1.0f - rt2[3]); if (fac == 0) { - memcpy(rt, rt2, 4 * sizeof(float)); + memcpy(rt, rt2, sizeof(float[4])); } else { rt[0] = fac * rt1[0] + rt2[0]; @@ -2522,7 +2522,7 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i } /* Allocate memory for the tempmap and the blur filter matrix */ - temp = MEM_mallocN((width * height * 4 * sizeof(float)), "blurbitmaptemp"); + temp = MEM_mallocN(sizeof(float[4]) * width * height, "blurbitmaptemp"); if (!temp) { return; } @@ -2746,8 +2746,8 @@ static void do_glow_effect_byte(Sequence *seq, float *outbuf, *inbuf; GlowVars *glow = (GlowVars *)seq->effectdata; - inbuf = MEM_mallocN(4 * sizeof(float) * x * y, "glow effect input"); - outbuf = MEM_mallocN(4 * sizeof(float) * x * y, "glow effect output"); + inbuf = MEM_mallocN(sizeof(float[4]) * x * y, "glow effect input"); + outbuf = MEM_mallocN(sizeof(float[4]) * x * y, "glow effect output"); IMB_buffer_float_from_byte(inbuf, rect1, IB_PROFILE_SRGB, IB_PROFILE_SRGB, false, x, y, x, x); IMB_buffer_float_premultiply(inbuf, x, y); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 6cdebcab904..dbcb83b8402 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3622,7 +3622,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat); memcpy(ibufs_arr[view_id]->rect_float, rres.rectf, - 4 * sizeof(float) * rres.rectx * rres.recty); + sizeof(float[4]) * rres.rectx * rres.recty); if (rres.rectz) { addzbuffloatImBuf(ibufs_arr[view_id]); diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index d38b70a33c8..1ab9766a7ec 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3280,8 +3280,8 @@ void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float ls if (!sb || !sb->bpoint) { return; } - opos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_OPOS"); - rpos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_RPOS"); + opos = MEM_callocN(sizeof(float[3]) * sb->totpoint, "SB_OPOS"); + rpos = MEM_callocN(sizeof(float[3]) * sb->totpoint, "SB_RPOS"); /* might filter vertex selection with a vertex group */ for (a = 0, bp = sb->bpoint, rp = sb->scratch->Ref.ivert; a < sb->totpoint; a++, bp++, rp++) { copy_v3_v3(rpos[a], rp->pos); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 060174c94a5..b72c5e99b43 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -957,7 +957,7 @@ void BKE_sound_read_waveform(Main *bmain, bSound *sound, short *stop) if (info.length > 0) { int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND; - waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples"); + waveform->data = MEM_mallocN(sizeof(float[3]) * length, "SoundWaveform.samples"); waveform->length = AUD_readSound( sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND, stop); } diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 68626bdc8dd..10830a3d4ba 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -693,7 +693,7 @@ static void studiolight_calculate_cubemap_vector_weight( static void studiolight_spherical_harmonics_calculate_coefficients(StudioLight *sl, float (*sh)[3]) { float weight_accum = 0.0f; - memset(sh, 0, sizeof(float) * 3 * STUDIOLIGHT_SH_COEFS_LEN); + memset(sh, 0, sizeof(float[3]) * STUDIOLIGHT_SH_COEFS_LEN); for (int face = 0; face < 6; face++) { ITER_PIXELS (float, diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index c992990e0a0..86c57491393 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -85,7 +85,7 @@ static int element_size_bytes_get(const SubdivCCG *subdiv_ccg) static void subdiv_ccg_init_layers(SubdivCCG *subdiv_ccg, const SubdivToCCGSettings *settings) { /* CCG always contains coordinates. Rest of layers are coming after them. */ - int layer_offset = sizeof(float) * 3; + int layer_offset = sizeof(float[3]); /* Mask. */ if (settings->need_mask) { subdiv_ccg->has_mask = true; @@ -103,7 +103,7 @@ static void subdiv_ccg_init_layers(SubdivCCG *subdiv_ccg, const SubdivToCCGSetti if (settings->need_normal) { subdiv_ccg->has_normal = true; subdiv_ccg->normal_offset = layer_offset; - layer_offset += sizeof(float) * 3; + layer_offset += sizeof(float[3]); } else { subdiv_ccg->has_normal = false; @@ -709,7 +709,7 @@ static void subdiv_ccg_recalc_inner_face_normals(SubdivCCG *subdiv_ccg, CCGElem *grid = subdiv_ccg->grids[grid_index]; if (tls->face_normals == NULL) { tls->face_normals = MEM_malloc_arrayN( - grid_size_1 * grid_size_1, 3 * sizeof(float), "CCG TLS normals"); + grid_size_1 * grid_size_1, sizeof(float[3]), "CCG TLS normals"); } for (int y = 0; y < grid_size - 1; y++) { for (int x = 0; x < grid_size - 1; x++) { diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 98386a3356a..45dca79342e 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -150,7 +150,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int numLaye ifc.vertDataSize = sizeof(float) * numLayers; normalOffset += sizeof(float) * numLayers; if (flags & CCG_CALC_NORMALS) { - ifc.vertDataSize += sizeof(float) * 3; + ifc.vertDataSize += sizeof(float[3]); } if (flags & CCG_ALLOC_MASK) { ifc.vertDataSize += sizeof(float); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 8a1ebaf722b..7c34562e119 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -2823,7 +2823,7 @@ static void tracking_dopesheet_channels_segments_calc(MovieTrackingDopesheetChan return; } - channel->segments = MEM_callocN(2 * sizeof(int) * channel->tot_segment, + channel->segments = MEM_callocN(sizeof(int[2]) * channel->tot_segment, "tracking channel segments"); /* create segments */ 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; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3e814816cdb..e4644ea6e4d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1134,7 +1134,7 @@ static int *read_file_thumbnail(FileData *fd) const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0; int *data = (int *)(bhead + 1); - if (bhead->len < (2 * sizeof(int))) { + if (bhead->len < (sizeof(int[2]))) { break; } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 5127bdcb77b..fced95ee629 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3342,7 +3342,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256); + memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char[256])); } } } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index fa72e2a147d..88ccb551e16 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -102,7 +102,7 @@ static void vcol_to_fcol(Mesh *me) return; } - mcoln = mcolmain = MEM_malloc_arrayN(me->totface, 4 * sizeof(int), "mcoln"); + mcoln = mcolmain = MEM_malloc_arrayN(me->totface, sizeof(int[4]), "mcoln"); mcol = (uint *)me->mcol; mface = me->mface; for (a = me->totface; a > 0; a--, mface++) { diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 755fb73572d..890df78d904 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -4603,7 +4603,7 @@ void BLO_write_pointer_array(BlendWriter *writer, int size, const void *data_ptr void BLO_write_float3_array(BlendWriter *writer, int size, const float *data_ptr) { - BLO_write_raw(writer, sizeof(float) * 3 * size, data_ptr); + BLO_write_raw(writer, sizeof(float[3]) * size, data_ptr); } /** diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 4e9775bcfa7..6c4f98e125f 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -182,7 +182,7 @@ BMEdge *BM_edge_create( e->v2 = v2; e->l = NULL; - memset(&e->v1_disk_link, 0, sizeof(BMDiskLink) * 2); + memset(&e->v1_disk_link, 0, sizeof(BMDiskLink[2])); /* --- done --- */ bmesh_disk_edge_append(e, e->v1); diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 256ef55ac59..2f811dbe463 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -535,7 +535,7 @@ void BM_loop_interp_multires_ex(BMesh *UNUSED(bm), md_dst->totdisp = md_src->totdisp; md_dst->level = md_src->level; if (md_dst->totdisp) { - md_dst->disps = MEM_callocN(sizeof(float) * 3 * md_dst->totdisp, __func__); + md_dst->disps = MEM_callocN(sizeof(float[3]) * md_dst->totdisp, __func__); } else { return; diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.c b/source/blender/bmesh/intern/bmesh_mesh_convert.c index 65bc4da49bc..8db125970fd 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.c +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.c @@ -860,7 +860,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh if (act_is_basis) { const float(*fp)[3] = actkey->data; - ofs = MEM_callocN(sizeof(float) * 3 * bm->totvert, "currkey->data"); + ofs = MEM_callocN(sizeof(float[3]) * bm->totvert, "currkey->data"); mvert = me->mvert; BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) { const int keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset); diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 19e42b33c80..746e9668671 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -55,17 +55,17 @@ BLI_STATIC_ASSERT(ARRAY_SIZE(bmo_error_messages) == BMERR_TOTAL, "message mismat /* operator slot type information - size of one element of the type given. */ const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES] = { - 0, /* 0: BMO_OP_SLOT_SENTINEL */ - sizeof(int), /* 1: BMO_OP_SLOT_BOOL */ - sizeof(int), /* 2: BMO_OP_SLOT_INT */ - sizeof(float), /* 3: BMO_OP_SLOT_FLT */ - sizeof(void *), /* 4: BMO_OP_SLOT_PNT */ - sizeof(void *), /* 5: BMO_OP_SLOT_PNT */ - 0, /* 6: unused */ - 0, /* 7: unused */ - sizeof(float) * 3, /* 8: BMO_OP_SLOT_VEC */ - sizeof(void *), /* 9: BMO_OP_SLOT_ELEMENT_BUF */ - sizeof(void *), /* 10: BMO_OP_SLOT_MAPPING */ + 0, /* 0: BMO_OP_SLOT_SENTINEL */ + sizeof(int), /* 1: BMO_OP_SLOT_BOOL */ + sizeof(int), /* 2: BMO_OP_SLOT_INT */ + sizeof(float), /* 3: BMO_OP_SLOT_FLT */ + sizeof(void *), /* 4: BMO_OP_SLOT_PNT */ + sizeof(void *), /* 5: BMO_OP_SLOT_PNT */ + 0, /* 6: unused */ + 0, /* 7: unused */ + sizeof(float[3]), /* 8: BMO_OP_SLOT_VEC */ + sizeof(void *), /* 9: BMO_OP_SLOT_ELEMENT_BUF */ + sizeof(void *), /* 10: BMO_OP_SLOT_MAPPING */ }; /* Dummy slot so there is something to return when slot name lookup fails */ @@ -418,7 +418,7 @@ void BMO_slot_mat_set(BMOperator *op, } slot->len = 4; - slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float) * 4 * 4); + slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float[4][4])); if (size == 4) { copy_m4_m4(slot->data.p, (float(*)[4])mat); diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c index 01bdf5d933a..a9879ce025a 100644 --- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c +++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c @@ -115,7 +115,7 @@ static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, in return NULL; } - sys->fweights = MEM_callocN(sizeof(float) * 3 * sys->numFaces, "ModLaplSmoothFWeight"); + sys->fweights = MEM_callocN(sizeof(float[3]) * sys->numFaces, "ModLaplSmoothFWeight"); if (!sys->fweights) { delete_laplacian_system(sys); return NULL; diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 8b814240a42..0ffd4f594e7 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -1968,10 +1968,10 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b bool need_2 = bp->seg != bp->pro_spacing.seg_2; if (pro->prof_co == NULL) { - pro->prof_co = (float *)BLI_memarena_alloc(bp->mem_arena, sizeof(float) * 3 * (bp->seg + 1)); + pro->prof_co = (float *)BLI_memarena_alloc(bp->mem_arena, sizeof(float[3]) * (bp->seg + 1)); if (need_2) { - pro->prof_co_2 = (float *)BLI_memarena_alloc( - bp->mem_arena, sizeof(float) * 3 * (bp->pro_spacing.seg_2 + 1)); + pro->prof_co_2 = (float *)BLI_memarena_alloc(bp->mem_arena, + sizeof(float[3]) * (bp->pro_spacing.seg_2 + 1)); } else { pro->prof_co_2 = pro->prof_co; diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 71cef9dc4da..8d55fe53aa7 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -65,11 +65,11 @@ void CompositorOperation::initExecution() this->m_depthInput = getInputSocketReader(2); if (this->getWidth() * this->getHeight() != 0) { this->m_outputBuffer = (float *)MEM_callocN( - this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation"); + sizeof(float[4]) * this->getWidth() * this->getHeight(), "CompositorOperation"); } if (this->m_depthInput != NULL) { this->m_depthBuffer = (float *)MEM_callocN( - this->getWidth() * this->getHeight() * sizeof(float), "CompositorOperation"); + sizeof(float) * this->getWidth() * this->getHeight(), "CompositorOperation"); } } diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cpp b/source/blender/compositor/operations/COM_DenoiseOperation.cpp index 202e614c0c5..4087056a79d 100644 --- a/source/blender/compositor/operations/COM_DenoiseOperation.cpp +++ b/source/blender/compositor/operations/COM_DenoiseOperation.cpp @@ -105,7 +105,7 @@ void DenoiseOperation::generateDenoise(float *data, inputTileColor->getWidth(), inputTileColor->getHeight(), 0, - 4 * sizeof(float)); + sizeof(float[4])); if (inputTileNormal && inputTileNormal->getBuffer()) { filter.setImage("normal", inputTileNormal->getBuffer(), @@ -113,7 +113,7 @@ void DenoiseOperation::generateDenoise(float *data, inputTileNormal->getWidth(), inputTileNormal->getHeight(), 0, - 3 * sizeof(float)); + sizeof(float[3])); } if (inputTileAlbedo && inputTileAlbedo->getBuffer()) { filter.setImage("albedo", @@ -122,7 +122,7 @@ void DenoiseOperation::generateDenoise(float *data, inputTileAlbedo->getWidth(), inputTileAlbedo->getHeight(), 0, - 4 * sizeof(float)); + sizeof(float[4])); } filter.setImage("output", data, @@ -130,7 +130,7 @@ void DenoiseOperation::generateDenoise(float *data, inputTileColor->getWidth(), inputTileColor->getHeight(), 0, - 4 * sizeof(float)); + sizeof(float[4])); BLI_assert(settings); if (settings) { @@ -158,5 +158,5 @@ void DenoiseOperation::generateDenoise(float *data, UNUSED_VARS(inputTileAlbedo, inputTileNormal, settings); ::memcpy(data, inputBufferColor, - inputTileColor->getWidth() * inputTileColor->getHeight() * sizeof(float) * 4); + sizeof(float[4]) * inputTileColor->getWidth() * inputTileColor->getHeight()); } diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp index 0f81780bb00..1e392b1f991 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp @@ -595,7 +595,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, float minspeed = (float)nbd->minspeed; float minspeedsq = minspeed * minspeed; - minvecbufrect = (float *)MEM_callocN(4 * sizeof(float) * xsize * ysize, "minspeed buf"); + minvecbufrect = (float *)MEM_callocN(sizeof(float[4]) * xsize * ysize, "minspeed buf"); dvec1 = vecbufrect; dvec2 = minvecbufrect; @@ -621,7 +621,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, } /* make vertex buffer with averaged speed and zvalues */ - rectvz = (float *)MEM_callocN(4 * sizeof(float) * (xsize + 1) * (ysize + 1), "vertices"); + rectvz = (float *)MEM_callocN(sizeof(float[4]) * (xsize + 1) * (ysize + 1), "vertices"); dvz = rectvz; for (y = 0; y <= ysize; y++) { 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) diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 4cbea0ded15..b2f687b49af 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -398,9 +398,9 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo correct_bezpart(v1, v2, v3, v4); BKE_curve_forward_diff_bezier( - v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3); + v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float[3])); BKE_curve_forward_diff_bezier( - v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3); + v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float[3])); for (int j = 0; j <= resol; ++j) { const float *fp = &data[j * 3]; diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index b3c58f2575b..ea9b0eb92b9 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -342,9 +342,9 @@ static void add_verts_to_dgroups(ReportList *reports, /* create an array of root and tip positions transformed into * global coords */ - root = MEM_callocN(numbones * sizeof(float) * 3, "root"); - tip = MEM_callocN(numbones * sizeof(float) * 3, "tip"); - selected = MEM_callocN(numbones * sizeof(int), "selected"); + root = MEM_callocN(sizeof(float[3]) * numbones, "root"); + tip = MEM_callocN(sizeof(float[3]) * numbones, "tip"); + selected = MEM_callocN(sizeof(int) * numbones, "selected"); for (j = 0; j < numbones; j++) { bone = bonelist[j]; diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 11066595e2e..75ffd31854a 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -223,7 +223,7 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac sys->verts = MEM_callocN(sizeof(float *) * totvert, "LaplacianSystemVerts"); sys->vpinned = MEM_callocN(sizeof(char) * totvert, "LaplacianSystemVpinned"); - sys->faces = MEM_callocN(sizeof(int) * 3 * totface, "LaplacianSystemFaces"); + sys->faces = MEM_callocN(sizeof(int[3]) * totface, "LaplacianSystemFaces"); sys->totvert = 0; sys->totface = 0; @@ -296,7 +296,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) } if (sys->storeweights) { - sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight"); + sys->fweights = MEM_callocN(sizeof(float[3]) * totface, "LaplacianFWeight"); } for (a = 0, face = sys->faces; a < totface; a++, face++) { @@ -568,7 +568,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys) float fnor[3]; int a, v1, v2, v3, (*face)[3]; - sys->heat.vnors = MEM_callocN(sizeof(float) * 3 * sys->totvert, "HeatVNors"); + sys->heat.vnors = MEM_callocN(sizeof(float[3]) * sys->totvert, "HeatVNors"); for (a = 0, face = sys->faces; a < sys->totface; a++, face++) { v1 = (*face)[0]; @@ -1762,7 +1762,7 @@ void ED_mesh_deform_bind_callback(MeshDeformModifierData *mmd, memset(&mdb, 0, sizeof(MeshDeformBind)); /* get mesh and cage mesh */ - mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos"); + mdb.vertexcos = MEM_callocN(sizeof(float[3]) * totvert, "MeshDeformCos"); mdb.totvert = totvert; mdb.cagemesh = cagemesh; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 69a05c9ae31..d113e0693a4 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -569,14 +569,14 @@ GHash *ED_curve_keyindex_hash_duplicate(GHash *keyindex) static void key_to_bezt(float *key, BezTriple *basebezt, BezTriple *bezt) { memcpy(bezt, basebezt, sizeof(BezTriple)); - memcpy(bezt->vec, key, sizeof(float) * 9); + memcpy(bezt->vec, key, sizeof(float[9])); bezt->tilt = key[9]; bezt->radius = key[10]; } static void bezt_to_key(BezTriple *bezt, float *key) { - memcpy(key, bezt->vec, sizeof(float) * 9); + memcpy(key, bezt->vec, sizeof(float[9])); key[9] = bezt->tilt; key[10] = bezt->radius; } @@ -691,7 +691,7 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs) nu = nu->next; } - ofs = MEM_callocN(sizeof(float) * 3 * totvec, "currkey->data"); + ofs = MEM_callocN(sizeof(float[3]) * totvec, "currkey->data"); nu = editnurb->nurbs.first; i = 0; while (nu) { @@ -3498,7 +3498,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, nextbezt)) { float prevvec[3][3]; - memcpy(prevvec, bezt->vec, sizeof(float) * 9); + memcpy(prevvec, bezt->vec, sizeof(float[9])); for (i = 0; i < number_cuts; i++) { factor = 1.0f / (number_cuts + 1 - i); @@ -3530,7 +3530,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) beztn->radius = (bezt->radius + nextbezt->radius) / 2; beztn->weight = (bezt->weight + nextbezt->weight) / 2; - memcpy(prevvec, beztn->vec, sizeof(float) * 9); + memcpy(prevvec, beztn->vec, sizeof(float[9])); beztn++; } } diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index 75d90df3291..19b05f0af0c 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -153,7 +153,7 @@ Nurb *ED_curve_add_nurbs_primitive( nu->resolu = cu->resolu; if (cutype == CU_BEZIER) { nu->pntsu = 2; - nu->bezt = (BezTriple *)MEM_callocN(2 * sizeof(BezTriple), "addNurbprim1"); + nu->bezt = (BezTriple *)MEM_callocN(sizeof(BezTriple) * nu->pntsu, "addNurbprim1"); bezt = nu->bezt; bezt->h1 = bezt->h2 = HD_ALIGN; bezt->f1 = bezt->f2 = bezt->f3 = SELECT; @@ -190,7 +190,7 @@ Nurb *ED_curve_add_nurbs_primitive( nu->pntsu = 4; nu->pntsv = 1; nu->orderu = 4; - nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * 4, "addNurbprim3"); + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "addNurbprim3"); bp = nu->bp; for (a = 0; a < 4; a++, bp++) { @@ -227,7 +227,7 @@ Nurb *ED_curve_add_nurbs_primitive( nu->orderu = 5; nu->flagu = CU_NURB_ENDPOINT; /* endpoint */ nu->resolu = cu->resolu; - nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * 5, "addNurbprim3"); + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "addNurbprim3"); bp = nu->bp; for (a = 0; a < 5; a++, bp++) { @@ -262,7 +262,7 @@ Nurb *ED_curve_add_nurbs_primitive( if (cutype == CU_BEZIER) { nu->pntsu = 4; - nu->bezt = (BezTriple *)MEM_callocN(sizeof(BezTriple) * 4, "addNurbprim1"); + nu->bezt = (BezTriple *)MEM_callocN(sizeof(BezTriple) * nu->pntsu, "addNurbprim1"); nu->flagu = CU_NURB_CYCLIC; bezt = nu->bezt; @@ -307,7 +307,7 @@ Nurb *ED_curve_add_nurbs_primitive( nu->pntsu = 8; nu->pntsv = 1; nu->orderu = 4; - nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * 8, "addNurbprim6"); + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "addNurbprim6"); nu->flagu = CU_NURB_CYCLIC; bp = nu->bp; @@ -406,7 +406,7 @@ Nurb *ED_curve_add_nurbs_primitive( nu->resolu = cu->resolu; nu->resolv = cu->resolv; nu->flag = CU_SMOOTH; - nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * 5, "addNurbprim6"); + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "addNurbprim6"); nu->flagu = 0; bp = nu->bp; diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c index 962a74d9e6f..5cc5e7ecdcd 100644 --- a/source/blender/editors/gpencil/gpencil_armature.c +++ b/source/blender/editors/gpencil/gpencil_armature.c @@ -308,10 +308,10 @@ static void gpencil_add_verts_to_dgroups( /* create an array of root and tip positions transformed into * global coords */ - root = MEM_callocN(numbones * sizeof(float) * 3, "root"); - tip = MEM_callocN(numbones * sizeof(float) * 3, "tip"); - selected = MEM_callocN(numbones * sizeof(int), "selected"); - radsqr = MEM_callocN(numbones * sizeof(float), "radsqr"); + root = MEM_callocN(sizeof(float[3]) * numbones, "root"); + tip = MEM_callocN(sizeof(float[3]) * numbones, "tip"); + selected = MEM_callocN(sizeof(int) * numbones, "selected"); + radsqr = MEM_callocN(sizeof(float) * numbones, "radsqr"); for (j = 0; j < numbones; j++) { bone = bonelist[j]; diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index aaf88e1a0b0..5aae10a5db5 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -2980,7 +2980,7 @@ bool ED_gpencil_stroke_point_is_inside(bGPDstroke *gps, int(*mcoords)[2] = NULL; int len = gps->totpoints; - mcoords = MEM_mallocN(sizeof(int) * 2 * len, __func__); + mcoords = MEM_mallocN(sizeof(int[2]) * len, __func__); /* Convert stroke to 2D array of points. */ bGPDspoint *pt; diff --git a/source/blender/editors/gpencil/gpencil_uv.c b/source/blender/editors/gpencil/gpencil_uv.c index e21b2049028..8304641611e 100644 --- a/source/blender/editors/gpencil/gpencil_uv.c +++ b/source/blender/editors/gpencil/gpencil_uv.c @@ -182,7 +182,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op) if (i > 0) { mul_v3_fl(center, 1.0f / i); /* Create arrays to save all transformations. */ - opdata->array_loc = MEM_calloc_arrayN(i, 2 * sizeof(float), __func__); + opdata->array_loc = MEM_calloc_arrayN(i, sizeof(float[2]), __func__); opdata->array_rot = MEM_calloc_arrayN(i, sizeof(float), __func__); opdata->array_scale = MEM_calloc_arrayN(i, sizeof(float), __func__); i = 0; diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index c19a5b8ef68..3dc6227434e 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -796,7 +796,7 @@ static void define_primitive_add_properties(wmOperatorType *ot) static int primitive_circle_add_exec(bContext *C, wmOperator *op) { const float points[4][2] = {{0.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f}, {0.5f, 0.0f}}; - int num_points = sizeof(points) / (2 * sizeof(float)); + int num_points = sizeof(points) / (sizeof(float[2])); create_primitive_from_points(C, op, points, num_points, HD_AUTO); @@ -827,7 +827,7 @@ void MASK_OT_primitive_circle_add(wmOperatorType *ot) static int primitive_square_add_exec(bContext *C, wmOperator *op) { const float points[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}}; - int num_points = sizeof(points) / (2 * sizeof(float)); + int num_points = sizeof(points) / (sizeof(float[2])); create_primitive_from_points(C, op, points, num_points, HD_VECT); diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index 74348f2c8cf..1eb6613d8fe 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -327,7 +327,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) if (MASKPOINT_ISSEL_ANY(point)) { if (do_location) { - memcpy(shape_ele_dst->value, shape_ele_src->value, sizeof(float) * 6); + memcpy(shape_ele_dst->value, shape_ele_src->value, sizeof(float[6])); } if (do_feather) { shape_ele_dst->value[6] = shape_ele_src->value[6]; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 29860de88f1..1e4144db47e 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4034,7 +4034,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) /* the floating point coordinates of verts in screen space will be * stored in a hash table according to the vertices pointer */ - screen_vert_coords = sco = MEM_mallocN(bm->totvert * sizeof(float) * 2, __func__); + screen_vert_coords = sco = MEM_mallocN(sizeof(float[2]) * bm->totvert, __func__); BM_ITER_MESH_INDEX (bv, &iter, bm, BM_VERTS_OF_MESH, i) { if (ED_view3d_project_float_object(region, bv->co, *sco, V3D_PROJ_TEST_CLIP_NEAR) != diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 4d84db9b35b..b96eeedd86f 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -452,7 +452,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) if (kb->data) { MEM_freeN(kb->data); } - kb->data = MEM_callocN(sizeof(float) * 3 * totvert, "join_shapekey"); + kb->data = MEM_callocN(sizeof(float[3]) * totvert, "join_shapekey"); kb->totelem = totvert; } } @@ -550,7 +550,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) BKE_keyblock_copy_settings(kbn, kb); /* adjust settings to fit (allocate a new data-array) */ - kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey"); + kbn->data = MEM_callocN(sizeof(float[3]) * totvert, "joined_shapekey"); kbn->totelem = totvert; } @@ -1154,7 +1154,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) int a; mirrorverts = MEM_callocN(sizeof(int) * totvert, "MirrorVerts"); - mirrorfaces = MEM_callocN(sizeof(int) * 2 * totface, "MirrorFaces"); + mirrorfaces = MEM_callocN(sizeof(int[2]) * totface, "MirrorFaces"); mvert = me_eval ? me_eval->mvert : me->mvert; mface = me_eval ? me_eval->mface : me->mface; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index f4de8f712c8..732d2f6ad52 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1175,7 +1175,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) else { /* clear inverse matrix and also the object location */ unit_m4(ob->parentinv); - memset(ob->loc, 0, 3 * sizeof(float)); + memset(ob->loc, 0, sizeof(float[3])); /* set recalc flags */ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 82a1139c860..488bb7121a2 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1386,7 +1386,7 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part totface = mesh->totface; /*totvert=dm->getNumVerts(dm);*/ /*UNUSED*/ - edit->emitter_cosnos = MEM_callocN(totface * 6 * sizeof(float), "emitter cosnos"); + edit->emitter_cosnos = MEM_callocN(sizeof(float[6]) * totface, "emitter cosnos"); edit->emitter_field = BLI_kdtree_3d_new(totface); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index d279958df8a..f75dd428968 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -349,7 +349,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R ED_annotation_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ); G.f &= ~G_FLAG_RENDER_VIEWPORT; - gp_rect = MEM_mallocN(sizex * sizey * sizeof(uchar) * 4, "offscreen rect"); + gp_rect = MEM_mallocN(sizeof(uchar[4]) * sizex * sizey, "offscreen rect"); GPU_offscreen_read_pixels(oglrender->ofs, GPU_DATA_UNSIGNED_BYTE, gp_rect); for (i = 0; i < sizex * sizey * 4; i += 4) { diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 85fc6927063..9d0e4efa0b3 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -764,7 +764,7 @@ static void shader_preview_texture(ShaderPreview *sp, Tex *tex, Scene *sce, Rend /* Create buffer in empty RenderView created in the init step. */ RenderResult *rr = RE_AcquireResultWrite(re); RenderView *rv = (RenderView *)rr->views.first; - rv->rectf = MEM_callocN(sizeof(float) * 4 * width * height, "texture render result"); + rv->rectf = MEM_callocN(sizeof(float[4]) * width * height, "texture render result"); RE_ReleaseResult(re); /* Get texture image pool (if any) */ diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 05eac574d9d..bcbb735d93d 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -566,7 +566,7 @@ int ED_draw_imbuf_method(ImBuf *ibuf) if (U.image_draw_method == IMAGE_DRAW_METHOD_AUTO) { /* Use faster GLSL when CPU to GPU transfer is unlikely to be a bottleneck, * otherwise do color management on CPU side. */ - const size_t threshold = 2048 * 2048 * 4 * sizeof(float); + const size_t threshold = sizeof(float[4]) * 2048 * 2048; const size_t data_size = (ibuf->rect_float) ? sizeof(float) : sizeof(uchar); const size_t size = ibuf->x * ibuf->y * ibuf->channels * data_size; diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index ba32b53a9e0..b8af33fb7cc 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1412,7 +1412,6 @@ static void paint_draw_2D_view_brush_cursor(PaintCursorContext *pcontext) pcontext->translation[1], pcontext->final_radius, 40); - } static void paint_draw_legacy_3D_view_brush_cursor(PaintCursorContext *pcontext) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index d16c66848b8..db7de01bee5 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1383,7 +1383,7 @@ static void insert_seam_vert_array(const ProjPaintState *ps, const int fidx[2] = {fidx1, ((fidx1 + 1) % 3)}; float vec[2]; - VertSeam *vseam = BLI_memarena_alloc(arena, sizeof(VertSeam) * 2); + VertSeam *vseam = BLI_memarena_alloc(arena, sizeof(VertSeam[2])); vseam->prev = NULL; vseam->next = NULL; @@ -2785,10 +2785,10 @@ static void project_bucket_clip_face(const bool is_ortho, } if (flip) { - qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort_flip); + qsort(isectVCosSS, *tot, sizeof(float[3]), float_z_sort_flip); } else { - qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort); + qsort(isectVCosSS, *tot, sizeof(float[3]), float_z_sort); } doubles = true; @@ -3872,7 +3872,7 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps) if (ps->do_mask_cavity) { int *counter = MEM_callocN(sizeof(int) * ps->totvert_eval, "counter"); - float(*edges)[3] = MEM_callocN(sizeof(float) * 3 * ps->totvert_eval, "edges"); + float(*edges)[3] = MEM_callocN(sizeof(float[3]) * ps->totvert_eval, "edges"); ps->cavities = MEM_mallocN(sizeof(float) * ps->totvert_eval, "ProjectPaint Cavities"); cavities = ps->cavities; diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index 21fba6479e8..7d318760476 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -522,12 +522,12 @@ static SculptClothSimulation *cloth_brush_simulation_create(SculptSession *ss, cloth_sim->capacity_length_constraints = CLOTH_LENGTH_CONSTRAINTS_BLOCK; cloth_sim->acceleration = MEM_calloc_arrayN( - totverts, 3 * sizeof(float), "cloth sim acceleration"); - cloth_sim->pos = MEM_calloc_arrayN(totverts, 3 * sizeof(float), "cloth sim pos"); - cloth_sim->prev_pos = MEM_calloc_arrayN(totverts, 3 * sizeof(float), "cloth sim prev pos"); + totverts, sizeof(float[3]), "cloth sim acceleration"); + cloth_sim->pos = MEM_calloc_arrayN(totverts, sizeof(float[3]), "cloth sim pos"); + cloth_sim->prev_pos = MEM_calloc_arrayN(totverts, sizeof(float[3]), "cloth sim prev pos"); cloth_sim->last_iteration_pos = MEM_calloc_arrayN( - totverts, sizeof(float) * 3, "cloth sim last iteration pos"); - cloth_sim->init_pos = MEM_calloc_arrayN(totverts, 3 * sizeof(float), "cloth sim init pos"); + totverts, sizeof(float[3]), "cloth sim last iteration pos"); + cloth_sim->init_pos = MEM_calloc_arrayN(totverts, sizeof(float[3]), "cloth sim init pos"); cloth_sim->length_constraint_tweak = MEM_calloc_arrayN( totverts, sizeof(float), "cloth sim length tweak"); @@ -535,7 +535,7 @@ static SculptClothSimulation *cloth_brush_simulation_create(SculptSession *ss, * positions. */ if (brush && SCULPT_is_cloth_deform_brush(brush)) { cloth_sim->deformation_pos = MEM_calloc_arrayN( - totverts, 3 * sizeof(float), "cloth sim deformation positions"); + totverts, sizeof(float[3]), "cloth sim deformation positions"); } cloth_sim->mass = cloth_mass; diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c index e39cdc2db23..ebf511c7fd3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c @@ -595,7 +595,7 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent } if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_SURFACE_SMOOTH) { - ss->filter_cache->surface_smooth_laplacian_disp = MEM_mallocN(3 * sizeof(float) * totvert, + ss->filter_cache->surface_smooth_laplacian_disp = MEM_mallocN(sizeof(float[3]) * totvert, "surface smooth disp"); ss->filter_cache->surface_smooth_shape_preservation = RNA_float_get( op->ptr, "surface_smooth_shape_preservation"); @@ -612,7 +612,7 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent ss->filter_cache->sharpen_factor = MEM_mallocN(sizeof(float) * totvert, "sharpen factor"); ss->filter_cache->sharpen_detail_directions = MEM_malloc_arrayN( - totvert, 3 * sizeof(float), "sharpen detail direction"); + totvert, sizeof(float[3]), "sharpen detail direction"); mesh_filter_sharpen_init_factors(ss); } diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c index bc493a036f0..aaa61ee9ed3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c +++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c @@ -359,7 +359,7 @@ static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent SCULPT_vertex_random_access_init(ss); - op->customdata = MEM_mallocN(2 * sizeof(float), "initial mouse position"); + op->customdata = MEM_mallocN(sizeof(float[2]), "initial mouse position"); copy_v2_v2(op->customdata, mouse); SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c index 00a59949130..ed33542967b 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c @@ -461,7 +461,7 @@ void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode if (SCULPT_stroke_is_first_brush_step(ss->cache)) { if (!ss->cache->prev_colors) { - ss->cache->prev_colors = MEM_callocN(sizeof(float) * 4 * totvert, "prev colors"); + ss->cache->prev_colors = MEM_callocN(sizeof(float[4]) * totvert, "prev colors"); for (int i = 0; i < totvert; i++) { copy_v4_v4(ss->cache->prev_colors[i], SCULPT_vertex_color_get(ss, i)); } diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c index 7fbbcd1c896..9a64830cc20 100644 --- a/source/blender/editors/sculpt_paint/sculpt_smooth.c +++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c @@ -443,7 +443,7 @@ void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in if (SCULPT_stroke_is_first_brush_step(ss->cache)) { BLI_assert(ss->cache->surface_smooth_laplacian_disp == NULL); ss->cache->surface_smooth_laplacian_disp = MEM_callocN( - SCULPT_vertex_count_get(ss) * 3 * sizeof(float), "HC smooth laplacian b"); + sizeof(float[3]) * SCULPT_vertex_count_get(ss), "HC smooth laplacian b"); } /* Threaded loop over nodes. */ diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 1d510d2989c..07bdd337269 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1515,7 +1515,7 @@ static void draw_tracking_tracks(SpaceClip *sc, /* undistort */ if (count) { - marker_pos = MEM_callocN(2 * sizeof(float) * count, "draw_tracking_tracks marker_pos"); + marker_pos = MEM_callocN(sizeof(float[2]) * count, "draw_tracking_tracks marker_pos"); track = tracksbase->first; fp = marker_pos; diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 5ae175f525f..f5861e792bc 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -810,9 +810,9 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 correct_bezpart(v1, v2, v3, v4); - BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3); + BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float[3])); BKE_curve_forward_diff_bezier( - v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3); + v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float[3])); for (fp = data; resol; resol--, fp += 3) { immVertex2fv(pos, fp); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 207f67aed1b..37daa881317 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3851,9 +3851,9 @@ bool node_link_bezier_points( if (node_link_bezier_handles(v2d, snode, link, vec)) { /* always do all three, to prevent data hanging around */ BKE_curve_forward_diff_bezier( - vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0] + 0, resol, sizeof(float) * 2); + vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0] + 0, resol, sizeof(float[2])); BKE_curve_forward_diff_bezier( - vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0] + 1, resol, sizeof(float) * 2); + vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0] + 1, resol, sizeof(float[2])); return 1; } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 4f50a18fc85..60058c82283 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1187,7 +1187,7 @@ static TreeElement *outliner_add_element(SpaceOutliner *space_outliner, c = RNA_property_array_item_char(prop, index); - te->name = MEM_callocN(sizeof(char) * 20, "OutlinerRNAArrayName"); + te->name = MEM_callocN(sizeof(char[20]), "OutlinerRNAArrayName"); if (c) { sprintf((char *)te->name, " %c", c); } diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 80b1c7a5194..ba573032350 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -730,7 +730,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) const float *src1 = src + 4 * (ibuf->x * y + x); const char *p; - memcpy(rgb, src1, 3 * sizeof(float)); + memcpy(rgb, src1, sizeof(float[3])); clamp_v3(rgb, 0.0f, 1.0f); diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 9c8d99d0d24..ce35a9f55ef 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -267,7 +267,7 @@ void setCustomPoints(TransInfo *UNUSED(t), { int *data; - mi->data = MEM_reallocN(mi->data, sizeof(int) * 4); + mi->data = MEM_reallocN(mi->data, sizeof(int[4])); data = mi->data; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 8e079dcac94..dd422f2443a 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -1498,10 +1498,10 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent float(*oldpoints)[2], (*newpoints)[2], *p1, *p2; size = npoints * 3; - oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonOldPoints"); - newpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonNewPoints"); + oldpoints = MEM_mallocN(sizeof(float[2]) * size, "PPolygonOldPoints"); + newpoints = MEM_mallocN(sizeof(float[2]) * size, "PPolygonNewPoints"); - memcpy(oldpoints, points, sizeof(float) * 2 * npoints); + memcpy(oldpoints, points, sizeof(float[2]) * npoints); for (i = 0; i < npoints; i++) { p1 = points[i]; @@ -1510,7 +1510,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent if (nnewpoints == 0) { /* degenerate case, use center of original polygon */ - memcpy(oldpoints, points, sizeof(float) * 2 * npoints); + memcpy(oldpoints, points, sizeof(float[2]) * npoints); nnewpoints = npoints; break; } @@ -1528,10 +1528,10 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent if (nnewpoints * 2 > size) { size *= 2; MEM_freeN(oldpoints); - oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "oldpoints"); - memcpy(oldpoints, newpoints, sizeof(float) * 2 * nnewpoints); + oldpoints = MEM_mallocN(sizeof(float[2]) * size, "oldpoints"); + memcpy(oldpoints, newpoints, sizeof(float[2]) * nnewpoints); MEM_freeN(newpoints); - newpoints = MEM_mallocN(sizeof(float) * 2 * size, "newpoints"); + newpoints = MEM_mallocN(sizeof(float[2]) * size, "newpoints"); } else { float(*sw_points)[2] = oldpoints; @@ -1687,7 +1687,7 @@ static void p_vert_harmonic_insert(PVert *v) npoints++; } - points = MEM_mallocN(sizeof(float) * 2 * npoints, "PHarmonicPoints"); + points = MEM_mallocN(sizeof(float[2]) * npoints, "PHarmonicPoints"); e = v->edge; i = 0; @@ -2427,7 +2427,7 @@ static void p_abf_setup_system(PAbfSystem *sys) sys->bAlpha = (float *)MEM_mallocN(sizeof(float) * sys->nangles, "ABFbalpha"); sys->bTriangle = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFbtriangle"); - sys->bInterior = (float *)MEM_mallocN(sizeof(float) * 2 * sys->ninterior, "ABFbinterior"); + sys->bInterior = (float *)MEM_mallocN(sizeof(float[2]) * sys->ninterior, "ABFbinterior"); sys->lambdaTriangle = (float *)MEM_callocN(sizeof(float) * sys->nfaces, "ABFlambdatri"); sys->lambdaPlanar = (float *)MEM_callocN(sizeof(float) * sys->ninterior, "ABFlamdaplane"); diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index f3ea7456c38..6332a6ab48f 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1225,14 +1225,14 @@ static int stitch_process_data(StitchStateContainer *ssc, uint buffer_index = 0; /* initialize the preview buffers */ - preview->preview_polys = MEM_mallocN(preview->preview_uvs * sizeof(float) * 2, + preview->preview_polys = MEM_mallocN(sizeof(float[2]) * preview->preview_uvs, "tri_uv_stitch_prev"); - preview->uvs_per_polygon = MEM_mallocN(preview->num_polys * sizeof(*preview->uvs_per_polygon), + preview->uvs_per_polygon = MEM_mallocN(sizeof(*preview->uvs_per_polygon) * preview->num_polys, "tri_uv_stitch_prev"); - preview->static_tris = MEM_mallocN(state->tris_per_island[ssc->static_island] * sizeof(float) * - 6, - "static_island_preview_tris"); + preview->static_tris = MEM_mallocN( + (sizeof(float[6]) * state->tris_per_island[ssc->static_island]), + "static_island_preview_tris"); preview->num_static_tris = state->tris_per_island[ssc->static_island]; /* will cause cancel and freeing of all data structures so OK */ @@ -1271,9 +1271,9 @@ static int stitch_process_data(StitchStateContainer *ssc, &bm->ldata, lnext->next->head.data, CD_MLOOPUV); luv = CustomData_bmesh_get(&bm->ldata, lnext->head.data, CD_MLOOPUV); - memcpy(preview->static_tris + buffer_index, fuv->uv, 2 * sizeof(float)); - memcpy(preview->static_tris + buffer_index + 2, luv->uv, 2 * sizeof(float)); - memcpy(preview->static_tris + buffer_index + 4, luvnext->uv, 2 * sizeof(float)); + memcpy(preview->static_tris + buffer_index, fuv->uv, sizeof(float[2])); + memcpy(preview->static_tris + buffer_index + 2, luv->uv, sizeof(float[2])); + memcpy(preview->static_tris + buffer_index + 4, luvnext->uv, sizeof(float[2])); buffer_index += 6; } else { diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp index 5681c65e5d2..d34be79cd66 100644 --- a/source/blender/freestyle/intern/application/AppCanvas.cpp +++ b/source/blender/freestyle/intern/application/AppCanvas.cpp @@ -122,7 +122,7 @@ void AppCanvas::Erase() void AppCanvas::readColorPixels(int x, int y, int w, int h, RGBImage &oImage) const { float *rgb = new float[3 * w * h]; - memset(rgb, 0, sizeof(float) * 3 * w * h); + memset(rgb, 0, sizeof(float[3]) * w * h); int xsch = width(); int ysch = height(); if (_pass_diffuse.buf) { @@ -161,8 +161,7 @@ void AppCanvas::readColorPixels(int x, int y, int w, int h, RGBImage &oImage) co if (ii < 0 || ii >= rectx) { continue; } - memcpy( - rgb + (w * j + i) * 3, _pass_diffuse.buf + (rectx * jj + ii) * 3, sizeof(float) * 3); + memcpy(rgb + (w * j + i) * 3, _pass_diffuse.buf + (rectx * jj + ii) * 3, sizeof(float[3])); } } } diff --git a/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp b/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp index ad2310d7875..052ae73da43 100644 --- a/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp +++ b/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp @@ -52,8 +52,8 @@ NodeCamera::NodeCamera(CameraType camera_type) : camera_type_(camera_type) #if 0 /* UNUSED, gives warning in gcc */ NodeCamera::NodeCamera(const NodeCamera &iBrother) : camera_type_(iBrother.camera_type_) { - memcpy(modelview_matrix_, iBrother.modelview_matrix_, 16 * sizeof(double)); - memcpy(projection_matrix_, iBrother.projection_matrix_, 16 * sizeof(double)); + memcpy(modelview_matrix_, iBrother.modelview_matrix_, sizeof(double[16])); + memcpy(projection_matrix_, iBrother.projection_matrix_, sizeof(double[16])); } #endif @@ -64,12 +64,12 @@ void NodeCamera::accept(SceneVisitor &v) void NodeCamera::setModelViewMatrix(double modelview_matrix[16]) { - memcpy(modelview_matrix_, modelview_matrix, 16 * sizeof(double)); + memcpy(modelview_matrix_, modelview_matrix, sizeof(double[16])); } void NodeCamera::setProjectionMatrix(double projection_matrix[16]) { - memcpy(projection_matrix_, projection_matrix, 16 * sizeof(double)); + memcpy(projection_matrix_, projection_matrix, sizeof(double[16])); } NodeOrthographicCamera::NodeOrthographicCamera() diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp index 46d4389ea83..2624c70c988 100644 --- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp +++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp @@ -124,7 +124,7 @@ void SilhouetteGeomEngine::setFrustum(real iZNear, real iZFar) void SilhouetteGeomEngine::retrieveViewport(int viewport[4]) { - memcpy(viewport, _viewport, 4 * sizeof(int)); + memcpy(viewport, _viewport, sizeof(int[4])); } void SilhouetteGeomEngine::ProjectSilhouette(vector &ioVertices) diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c index 619c37015e4..0f6daea50ef 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c @@ -147,9 +147,9 @@ static void duplicateStroke(Object *ob, normalize_v3(stroke_normal); } - float *t1_array = MEM_callocN(sizeof(float) * 3 * gps->totpoints, + float *t1_array = MEM_callocN(sizeof(float[3]) * gps->totpoints, "duplicate_temp_result_array_1"); - float *t2_array = MEM_callocN(sizeof(float) * 3 * gps->totpoints, + float *t2_array = MEM_callocN(sizeof(float[3]) * gps->totpoints, "duplicate_temp_result_array_2"); pt = gps->points; diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc index db3e0930d54..a6ba4d3d89a 100644 --- a/source/blender/gpu/intern/gpu_batch.cc +++ b/source/blender/gpu/intern/gpu_batch.cc @@ -1020,7 +1020,7 @@ void gpu_batch_init(void) float default_attrib_data[4] = {0.0f, 0.0f, 0.0f, 1.0f}; glBindBuffer(GL_ARRAY_BUFFER, g_default_attr_vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4, default_attrib_data, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(float[4]), default_attrib_data, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); } diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index d32b45e0b5f..83d70b32b7b 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -337,7 +337,7 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers, } } /* Face Sets. */ - memcpy(GPU_vertbuf_raw_step(&fset_step), face_set_color, sizeof(uchar) * 3); + memcpy(GPU_vertbuf_raw_step(&fset_step), face_set_color, sizeof(uchar[3])); } } } diff --git a/source/blender/gpu/intern/gpu_extensions.cc b/source/blender/gpu/intern/gpu_extensions.cc index 35b70a18363..8074e4b64f0 100644 --- a/source/blender/gpu/intern/gpu_extensions.cc +++ b/source/blender/gpu/intern/gpu_extensions.cc @@ -106,8 +106,7 @@ static struct GPUGlobal { static void gpu_detect_mip_render_workaround(void) { int cube_size = 2; - float *source_pix = (float *)MEM_callocN(sizeof(float) * 4 * 6 * cube_size * cube_size, - __func__); + float *source_pix = (float *)MEM_callocN(sizeof(float[4][6]) * cube_size * cube_size, __func__); float clear_color[4] = {1.0f, 0.5f, 0.0f, 0.0f}; GPUTexture *tex = GPU_texture_create_cube(cube_size, GPU_RGBA16F, source_pix, NULL); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 8d2003591e4..8df1f94238a 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -439,7 +439,7 @@ static void compute_sss_translucence_kernel(const GPUSssKernelData *kd, float **output) { float(*texels)[4]; - texels = MEM_callocN(sizeof(float) * 4 * resolution, "compute_sss_translucence_kernel"); + texels = MEM_callocN(sizeof(float[4]) * resolution, "compute_sss_translucence_kernel"); *output = (float *)texels; /* Last texel should be black, hence the - 1. */ diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 18942c9abb8..50785d7a857 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -139,7 +139,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon /* don't use the float buffer to save 8 bpp picture to prevent color banding * (there's no dithering algorithm behind the logImageSetDataRGBA function) */ - fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), + fbuf = (float *)MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y, "fbuf in imb_save_dpx_cineon"); for (y = 0; y < ibuf->y; y++) { @@ -158,7 +158,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon IMB_rect_from_float(ibuf); } - fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), + fbuf = (float *)MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y, "fbuf in imb_save_dpx_cineon"); if (fbuf == NULL) { printf("DPX/Cineon: error allocating memory.\n"); diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c index 362a558b505..6a81abd96e3 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.c +++ b/source/blender/imbuf/intern/cineon/logImageCore.c @@ -483,7 +483,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB memcpy(&mergedElement, &logImage->element[0], sizeof(LogImageElement)); mergedElement.descriptor = -1; mergedElement.depth = logImage->depth; - memset(&sortedElementData, -1, 8 * sizeof(int)); + memset(&sortedElementData, -1, sizeof(int[8])); /* Try to know how to assemble the elements */ for (i = 0; i < logImage->numElements; i++) { diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 08e1bc5f674..2c42d59a2d9 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -2342,7 +2342,7 @@ void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer, } } else { - memcpy(out, in, sizeof(float) * 4 * width); + memcpy(out, in, sizeof(float[4]) * width); } } } @@ -3511,7 +3511,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf, size_t display_offset = ((size_t)display_stride * i + xmin) * 4; memcpy( - display_buffer + display_offset, byte_buffer + byte_offset, 4 * sizeof(char) * width); + display_buffer + display_offset, byte_buffer + byte_offset, sizeof(char[4]) * width); } } } diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index bcc8488089d..798849f2dd4 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -666,7 +666,7 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, if (profile_to == profile_from) { /* same profile, copy */ - memcpy(to, from, sizeof(uchar) * 4 * width); + memcpy(to, from, sizeof(uchar[4]) * width); } else if (profile_to == IB_PROFILE_LINEAR_RGB) { /* convert to sRGB to linear */ @@ -785,7 +785,7 @@ void IMB_float_from_rect(ImBuf *ibuf) size_t size; size = ((size_t)ibuf->x) * ibuf->y; - size = size * 4 * sizeof(float); + size = sizeof(float[4]) * size; ibuf->channels = 4; rect_float = MEM_callocN(size, "IMB_float_from_rect"); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index a5b977be2ce..2244a9c3051 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -896,7 +896,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) h = ibuf->y; /* initialize image components */ - memset(&cmptparm, 0, 4 * sizeof(opj_image_cmptparm_t)); + memset(&cmptparm, 0, sizeof(opj_image_cmptparm_t[4])); for (i = 0; i < numcomps; i++) { cmptparm[i].prec = prec; cmptparm[i].bpp = prec; diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index f7b033869e3..e395222a214 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -536,7 +536,7 @@ void IMB_moviecache_get_cache_segments( if (totseg) { int b, *points; - points = MEM_callocN(2 * sizeof(int) * totseg, "movieclip cache segments"); + points = MEM_callocN(sizeof(int[2]) * totseg, "movieclip cache segments"); /* fill */ for (a = 0, b = 0; a < totframe; a++) { diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index a4e4d41472f..67bb3677834 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -1976,7 +1976,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem, const bool has_luma = exr_has_luma(*file); FrameBuffer frameBuffer; float *first; - int xstride = sizeof(float) * 4; + int xstride = sizeof(float[4]); int ystride = -xstride * width; imb_addrectfloatImBuf(ibuf); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 91787d64525..8b4f33bb306 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -610,7 +610,7 @@ void IMB_rectblend(ImBuf *dbuf, } if (do_float) { - memcpy(drectf, srectf, width * sizeof(float) * 4); + memcpy(drectf, srectf, sizeof(float[4]) * width); drectf += destskip * 4; srectf += srcskip * 4; } diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 17b485b5171..c2fc2190ce5 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -108,11 +108,11 @@ void IMB_flipx(struct ImBuf *ibuf) if (ibuf->rect_float) { for (yi = y - 1; yi >= 0; yi--) { for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { - memcpy(&px_f, &ibuf->rect_float[((x * yi) + xr) * 4], 4 * sizeof(float)); + memcpy(&px_f, &ibuf->rect_float[((x * yi) + xr) * 4], sizeof(float[4])); memcpy(&ibuf->rect_float[((x * yi) + xr) * 4], &ibuf->rect_float[((x * yi) + xl) * 4], - 4 * sizeof(float)); - memcpy(&ibuf->rect_float[((x * yi) + xl) * 4], &px_f, 4 * sizeof(float)); + sizeof(float[4])); + memcpy(&ibuf->rect_float[((x * yi) + xl) * 4], &px_f, sizeof(float[4])); } } } diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index cecb683b0bd..1fd9bba68f3 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -886,7 +886,7 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy) } if (ibuf->rect) { - unsigned char *newrect = MEM_mallocN(newx * newy * sizeof(int), "q_scale rect"); + unsigned char *newrect = MEM_mallocN(sizeof(int) * newx * newy, "q_scale rect"); q_scale_byte((unsigned char *)ibuf->rect, newrect, ibuf->x, ibuf->y, newx, newy); imb_freerectImBuf(ibuf); @@ -894,7 +894,7 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy) ibuf->rect = (unsigned int *)newrect; } if (ibuf->rect_float) { - float *newrect = MEM_mallocN(newx * newy * 4 * sizeof(float), "q_scale rectfloat"); + float *newrect = MEM_mallocN(sizeof(float[4]) * newx * newy, "q_scale rectfloat"); q_scale_float(ibuf->rect_float, newrect, ibuf->x, ibuf->y, newx, newy); imb_freerectfloatImBuf(ibuf); ibuf->mall |= IB_rectfloat; @@ -927,13 +927,13 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx) } if (do_rect) { - _newrect = MEM_mallocN(newx * ibuf->y * sizeof(uchar) * 4, "scaledownx"); + _newrect = MEM_mallocN(sizeof(uchar[4]) * newx * ibuf->y, "scaledownx"); if (_newrect == NULL) { return ibuf; } } if (do_float) { - _newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaledownxf"); + _newrectf = MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaledownxf"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); @@ -1068,13 +1068,13 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy) } if (do_rect) { - _newrect = MEM_mallocN(newy * ibuf->x * sizeof(uchar) * 4, "scaledowny"); + _newrect = MEM_mallocN(sizeof(uchar[4]) * newy * ibuf->x, "scaledowny"); if (_newrect == NULL) { return ibuf; } } if (do_float) { - _newrectf = MEM_mallocN(newy * ibuf->x * sizeof(float) * 4, "scaledownyf"); + _newrectf = MEM_mallocN(sizeof(float[4]) * newy * ibuf->x, "scaledownyf"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); @@ -1225,7 +1225,7 @@ static ImBuf *scaleupx(struct ImBuf *ibuf, int newx) } if (ibuf->rect_float) { do_float = true; - _newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaleupxf"); + _newrectf = MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaleupxf"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); @@ -1401,7 +1401,7 @@ static ImBuf *scaleupy(struct ImBuf *ibuf, int newy) } if (ibuf->rect_float) { do_float = true; - _newrectf = MEM_mallocN(ibuf->x * newy * sizeof(float) * 4, "scaleupyf"); + _newrectf = MEM_mallocN(sizeof(float[4]) * ibuf->x * newy, "scaleupyf"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); @@ -1703,7 +1703,7 @@ bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy } if (do_float) { - _newrectf = MEM_mallocN(newx * newy * sizeof(float) * 4, "scalefastimbuf f"); + _newrectf = MEM_mallocN(sizeof(float[4]) * newx * newy, "scalefastimbuf f"); if (_newrectf == NULL) { if (_newrect) { MEM_freeN(_newrect); diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c index 1a46572fb20..58ff8473a85 100644 --- a/source/blender/imbuf/intern/util_gpu.c +++ b/source/blender/imbuf/intern/util_gpu.c @@ -103,7 +103,7 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, * convention, no colorspace conversion needed. But we do require 4 channels * currently. */ if (ibuf->channels != 4 || !store_premultiplied) { - data_rect = MEM_mallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, __func__); + data_rect = MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y, __func__); *r_freedata = true; if (data_rect == NULL) { @@ -123,7 +123,7 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, * We must also convert to premultiplied for correct texture interpolation * and consistency with float images. */ if (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) { - data_rect = MEM_mallocN(sizeof(uchar) * 4 * ibuf->x * ibuf->y, __func__); + data_rect = MEM_mallocN(sizeof(uchar[4]) * ibuf->x * ibuf->y, __func__); *r_freedata = true; if (data_rect == NULL) { diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index bb791dd6e2d..e94dad59176 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -4384,7 +4384,7 @@ void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropert int tot = *totitem; if (tot == 0) { - *items = MEM_callocN(sizeof(EnumPropertyItem) * 8, __func__); + *items = MEM_callocN(sizeof(EnumPropertyItem[8]), __func__); } else if (tot >= 8 && (tot & (tot - 1)) == 0) { /* power of two > 8 */ diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 27297a4d19a..b8500264e12 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -815,7 +815,7 @@ static void rna_trackingCameras_matrix_from_frame(ID *id, MovieTrackingObject *object = find_object_for_reconstruction(tracking, reconstruction); BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, framenr, mat); - memcpy(matrix, mat, sizeof(float) * 16); + memcpy(matrix, mat, sizeof(float[4][4])); } #else diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 0567b22d23f..90873fa73f4 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1088,7 +1088,7 @@ int rna_show_statusbar_vram_editable(struct PointerRNA *UNUSED(ptr), const char static size_t max_memory_in_megabytes(void) { /* Maximum addressable bytes on this platform. */ - const size_t limit_bytes = (((size_t)1) << ((sizeof(size_t) * 8) - 1)); + const size_t limit_bytes = (((size_t)1) << ((sizeof(size_t[8])) - 1)); /* Convert it to megabytes and return. */ return (limit_bytes >> 20); } diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index f3ee14e0206..0cd3430f009 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -121,7 +121,7 @@ static void deformVerts(ModifierData *md, &mesh_src->vdata, CD_CLOTH_ORCO, CD_CALLOC, NULL, mesh_src->totvert); } - memcpy(layerorco, kb->data, sizeof(float) * 3 * numVerts); + memcpy(layerorco, kb->data, sizeof(float[3]) * numVerts); } } diff --git a/source/blender/modifiers/intern/MOD_meshcache_mdd.c b/source/blender/modifiers/intern/MOD_meshcache_mdd.c index 6787ef5b47e..cb150976ff5 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_mdd.c +++ b/source/blender/modifiers/intern/MOD_meshcache_mdd.c @@ -160,7 +160,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp, return false; } - if (BLI_fseek(fp, sizeof(float) * 3 * index * mdd_head.verts_tot, SEEK_CUR) != 0) { + if (BLI_fseek(fp, sizeof(float[3]) * index * mdd_head.verts_tot, SEEK_CUR) != 0) { *err_str = "Failed to seek frame"; return false; } @@ -170,7 +170,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp, float *vco = *vertexCos; uint i; for (i = mdd_head.verts_tot; i != 0; i--, vco += 3) { - fread(vco, sizeof(float) * 3, 1, fp); + fread(vco, sizeof(float[3]), 1, fp); # ifdef __LITTLE_ENDIAN__ BLI_endian_switch_float(vco + 0); @@ -180,7 +180,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp, } #else /* no blending */ - if (!fread(vertexCos, sizeof(float) * 3, mdd_head.verts_tot, f)) { + if (!fread(vertexCos, sizeof(float[3]), mdd_head.verts_tot, f)) { *err_str = errno ? strerror(errno) : "Failed to read frame"; return false; } @@ -195,7 +195,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp, uint i; for (i = mdd_head.verts_tot; i != 0; i--, vco += 3) { float tvec[3]; - fread(tvec, sizeof(float) * 3, 1, fp); + fread(tvec, sizeof(float[3]), 1, fp); #ifdef __LITTLE_ENDIAN__ BLI_endian_switch_float(tvec + 0); diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.c b/source/blender/modifiers/intern/MOD_meshcache_pc2.c index 1ea71730db7..120d1d6d71a 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_pc2.c +++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.c @@ -146,7 +146,7 @@ bool MOD_meshcache_read_pc2_index(FILE *fp, return false; } - if (BLI_fseek(fp, sizeof(float) * 3 * index * pc2_head.verts_tot, SEEK_CUR) != 0) { + if (BLI_fseek(fp, sizeof(float[3]) * index * pc2_head.verts_tot, SEEK_CUR) != 0) { *err_str = "Failed to seek frame"; return false; } @@ -155,7 +155,7 @@ bool MOD_meshcache_read_pc2_index(FILE *fp, float *vco = *vertexCos; uint i; for (i = pc2_head.verts_tot; i != 0; i--, vco += 3) { - fread(vco, sizeof(float) * 3, 1, fp); + fread(vco, sizeof(float[3]), 1, fp); #ifdef __BIG_ENDIAN__ BLI_endian_switch_float(vco + 0); @@ -170,7 +170,7 @@ bool MOD_meshcache_read_pc2_index(FILE *fp, uint i; for (i = pc2_head.verts_tot; i != 0; i--, vco += 3) { float tvec[3]; - fread(tvec, sizeof(float) * 3, 1, fp); + fread(tvec, sizeof(float[3]), 1, fp); #ifdef __BIG_ENDIAN__ BLI_endian_switch_float(tvec + 0); diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 1bf07bdefbb..a0c4799a46f 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -1276,7 +1276,7 @@ static void skin_choose_quad_bridge_order(BMVert *a[4], BMVert *b[4], int best_o if (len < shortest_len) { shortest_len = len; - memcpy(best_order, orders[i], sizeof(int) * 4); + memcpy(best_order, orders[i], sizeof(int[4])); } } } diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c index 7a4c45b73bd..818327e120b 100644 --- a/source/blender/modifiers/intern/MOD_solidify_extrude.c +++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c @@ -355,7 +355,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) { - vert_nors = MEM_calloc_arrayN(numVerts, 3 * sizeof(float), "mod_solid_vno_hq"); + vert_nors = MEM_calloc_arrayN(numVerts, sizeof(float[3]), "mod_solid_vno_hq"); mesh_calc_hq_normal(mesh, poly_nors, vert_nors); } @@ -726,13 +726,13 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex #endif /* same as EM_solidify() in editmesh_lib.c */ float *vert_angles = MEM_calloc_arrayN( - numVerts, 2 * sizeof(float), "mod_solid_pair"); /* 2 in 1 */ + numVerts, sizeof(float[2]), "mod_solid_pair"); /* 2 in 1 */ float *vert_accum = vert_angles + numVerts; uint vidx; uint i; if (vert_nors == NULL) { - vert_nors = MEM_malloc_arrayN(numVerts, 3 * sizeof(float), "mod_solid_vno"); + vert_nors = MEM_malloc_arrayN(numVerts, sizeof(float[3]), "mod_solid_vno"); for (i = 0, mv = mvert; i < numVerts; i++, mv++) { normal_short_to_float_v3(vert_nors[i], mv->no); } @@ -1044,7 +1044,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex const bool do_side_normals = !(result->runtime.cd_dirty_vert & CD_MASK_NORMAL); /* annoying to allocate these since we only need the edge verts, */ float(*edge_vert_nos)[3] = do_side_normals ? - MEM_calloc_arrayN(numVerts, 3 * sizeof(float), __func__) : + MEM_calloc_arrayN(numVerts, sizeof(float[3]), __func__) : NULL; float nor[3]; #endif diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index b30aafbf875..3ee6e766413 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -483,7 +483,7 @@ static PyObject *Vector_resize_2d(VectorObject *self) return NULL; } - self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2)); + self->vec = PyMem_Realloc(self->vec, sizeof(float[2])); if (self->vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_2d(): " @@ -514,7 +514,7 @@ static PyObject *Vector_resize_3d(VectorObject *self) return NULL; } - self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3)); + self->vec = PyMem_Realloc(self->vec, sizeof(float[3])); if (self->vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_3d(): " @@ -549,7 +549,7 @@ static PyObject *Vector_resize_4d(VectorObject *self) return NULL; } - self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4)); + self->vec = PyMem_Realloc(self->vec, sizeof(float[4])); if (self->vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_4d(): " diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 0fc389ecd93..3236026c69f 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2779,7 +2779,7 @@ void RE_layer_load_from_file( IMB_float_from_rect(ibuf); } - memcpy(rpass->rect, ibuf->rect_float, sizeof(float) * 4 * layer->rectx * layer->recty); + memcpy(rpass->rect, ibuf->rect_float, sizeof(float[4]) * layer->rectx * layer->recty); } else { if ((ibuf->x - x >= layer->rectx) && (ibuf->y - y >= layer->recty)) { @@ -2794,7 +2794,7 @@ void RE_layer_load_from_file( IMB_rectcpy(ibuf_clip, ibuf, 0, 0, x, y, layer->rectx, layer->recty); memcpy( - rpass->rect, ibuf_clip->rect_float, sizeof(float) * 4 * layer->rectx * layer->recty); + rpass->rect, ibuf_clip->rect_float, sizeof(float[4]) * layer->rectx * layer->recty); IMB_freeImBuf(ibuf_clip); } else { diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index db3ae8d8b5e..12b80da9f59 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -770,7 +770,7 @@ static void pointdensity_color( static void sample_dummy_point_density(int resolution, float *values) { - memset(values, 0, sizeof(float) * 4 * resolution * resolution * resolution); + memset(values, 0, sizeof(float[4]) * resolution * resolution * resolution); } static void particle_system_minmax(Depsgraph *depsgraph, diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 8b5f2778728..ef44c896a25 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -1507,10 +1507,10 @@ void RE_render_result_rect_from_ibuf(RenderResult *rr, rr->have_combined = true; if (!rv->rectf) { - rv->rectf = MEM_mallocN(4 * sizeof(float) * rr->rectx * rr->recty, "render_seq rectf"); + rv->rectf = MEM_mallocN(sizeof(float[4]) * rr->rectx * rr->recty, "render_seq rectf"); } - memcpy(rv->rectf, ibuf->rect_float, 4 * sizeof(float) * rr->rectx * rr->recty); + memcpy(rv->rectf, ibuf->rect_float, sizeof(float[4]) * rr->rectx * rr->recty); /* TSK! Since sequence render doesn't free the *rr render result, the old rect32 * can hang around when sequence render has rendered a 32 bits one before */ @@ -1535,7 +1535,7 @@ void render_result_rect_fill_zero(RenderResult *rr, const int view_id) RenderView *rv = RE_RenderViewGetById(rr, view_id); if (rv->rectf) { - memset(rv->rectf, 0, 4 * sizeof(float) * rr->rectx * rr->recty); + memset(rv->rectf, 0, sizeof(float[4]) * rr->rectx * rr->recty); } else if (rv->rect32) { memset(rv->rect32, 0, 4 * rr->rectx * rr->recty); diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c index ccc26233e3a..b4912492678 100644 --- a/source/blender/simulation/intern/implicit_blender.c +++ b/source/blender/simulation/intern/implicit_blender.c @@ -362,7 +362,7 @@ static void print_bfmatrix(fmatrix3x3 *m) /* copy 3x3 matrix */ DO_INLINE void cp_fmatrix(float to[3][3], const float from[3][3]) { - // memcpy(to, from, sizeof (float) * 9); + // memcpy(to, from, sizeof(float[3][3])); copy_v3_v3(to[0], from[0]); copy_v3_v3(to[1], from[1]); copy_v3_v3(to[2], from[2]); -- cgit v1.2.3