diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-08-08 06:29:21 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-08-08 06:38:00 +0300 |
commit | 171e77c3c25a1224fc5f7db40ec6f8879f8dbbb0 (patch) | |
tree | ea51f4fa508a39807e6f6d333b2d53af8a2b9fc1 /source/blender/editors | |
parent | 4bf3ca20165959f98c7c830a138ba2901d3dd851 (diff) |
Cleanup: use array syntax for sizeof with fixed values
Also order sizeof(..) first to promote other values to size_t.
Diffstat (limited to 'source/blender/editors')
32 files changed, 78 insertions, 79 deletions
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 { |