[Bf-blender-cvs] [c594cfbe504] master: Cleanup: use array syntax for sizeof, zero before float suffix

Campbell Barton noreply at git.blender.org
Fri Mar 25 02:12:51 CET 2022


Commit: c594cfbe50497fdc365b3f327b643de507cda02f
Author: Campbell Barton
Date:   Fri Mar 25 12:04:19 2022 +1100
Branches: master
https://developer.blender.org/rBc594cfbe50497fdc365b3f327b643de507cda02f

Cleanup: use array syntax for sizeof, zero before float suffix

===================================================================

M	intern/ghost/intern/GHOST_XrControllerModel.cpp
M	source/blender/editors/animation/keyframes_edit.c
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/sculpt_paint/sculpt_boundary.c
M	source/blender/editors/sculpt_paint/sculpt_smooth.c
M	source/blender/io/usd/intern/usd_capi_import.cc
M	source/blender/render/intern/texture_margin.cc

===================================================================

diff --git a/intern/ghost/intern/GHOST_XrControllerModel.cpp b/intern/ghost/intern/GHOST_XrControllerModel.cpp
index 78d81651e92..5be3a8e70ad 100644
--- a/intern/ghost/intern/GHOST_XrControllerModel.cpp
+++ b/intern/ghost/intern/GHOST_XrControllerModel.cpp
@@ -234,7 +234,7 @@ static void calc_node_transforms(const tinygltf::Node &gltf_node,
                      {(float)dm[4], (float)dm[5], (float)dm[6], (float)dm[7]},
                      {(float)dm[8], (float)dm[9], (float)dm[10], (float)dm[11]},
                      {(float)dm[12], (float)dm[13], (float)dm[14], (float)dm[15]}};
-    memcpy(r_local_transform, m, sizeof(float) * 16);
+    memcpy(r_local_transform, m, sizeof(float[4][4]));
   }
   else {
     /* No matrix is present, so construct a matrix from the TRS values (each one is optional). */
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index f18873cc22b..ed40845a47c 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -1292,8 +1292,8 @@ void ANIM_fcurve_equalize_keyframes_loop(FCurve *fcu,
 {
   uint i;
   BezTriple *bezt;
-  const float flat_direction_left[2] = {-handle_length, 0.f};
-  const float flat_direction_right[2] = {handle_length, 0.f};
+  const float flat_direction_left[2] = {-handle_length, 0.0f};
+  const float flat_direction_right[2] = {handle_length, 0.0f};
 
   /* Loop through an F-Curves keyframes. */
   for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index db74d86d0f4..5e89a4823db 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -1076,7 +1076,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
   const int trim_totpolys = (2 * (tot_screen_points - 2)) + (2 * tot_screen_points);
   trim_operation->mesh = BKE_mesh_new_nomain(
       trim_totverts, 0, 0, trim_totpolys * 3, trim_totpolys);
-  trim_operation->true_mesh_co = MEM_malloc_arrayN(trim_totverts, 3 * sizeof(float), "mesh orco");
+  trim_operation->true_mesh_co = MEM_malloc_arrayN(trim_totverts, sizeof(float[3]), "mesh orco");
 
   float depth_front = trim_operation->depth_front;
   float depth_back = trim_operation->depth_back;
@@ -1130,7 +1130,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
 
   /* Get the triangulation for the front/back poly. */
   const int tot_tris_face = tot_screen_points - 2;
-  uint(*r_tris)[3] = MEM_malloc_arrayN(tot_tris_face, 3 * sizeof(uint), "tris");
+  uint(*r_tris)[3] = MEM_malloc_arrayN(tot_tris_face, sizeof(uint[3]), "tris");
   BLI_polyfill_calc(screen_points, tot_screen_points, 0, r_tris);
 
   /* Write the front face triangle indices. */
diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c
index 70f8f2127b4..8bf09ce3d05 100644
--- a/source/blender/editors/sculpt_paint/sculpt_boundary.c
+++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c
@@ -532,9 +532,8 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss, SculptBoundary *bo
 {
   const int totvert = SCULPT_vertex_count_get(ss);
   boundary->bend.pivot_rotation_axis = MEM_calloc_arrayN(
-      totvert, 3 * sizeof(float), "pivot rotation axis");
-  boundary->bend.pivot_positions = MEM_calloc_arrayN(
-      totvert, 3 * sizeof(float), "pivot positions");
+      totvert, sizeof(float[3]), "pivot rotation axis");
+  boundary->bend.pivot_positions = MEM_calloc_arrayN(totvert, sizeof(float[3]), "pivot positions");
 
   for (int i = 0; i < totvert; i++) {
     if (boundary->edit_info[i].num_propagation_steps != boundary->max_propagation_steps) {
@@ -567,7 +566,7 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss, SculptBoundary *bo
 static void sculpt_boundary_slide_data_init(SculptSession *ss, SculptBoundary *boundary)
 {
   const int totvert = SCULPT_vertex_count_get(ss);
-  boundary->slide.directions = MEM_calloc_arrayN(totvert, 3 * sizeof(float), "slide directions");
+  boundary->slide.directions = MEM_calloc_arrayN(totvert, sizeof(float[3]), "slide directions");
 
   for (int i = 0; i < totvert; i++) {
     if (boundary->edit_info[i].num_propagation_steps != boundary->max_propagation_steps) {
@@ -592,7 +591,7 @@ static void sculpt_boundary_twist_data_init(SculptSession *ss, SculptBoundary *b
 {
   zero_v3(boundary->twist.pivot_position);
   float(*poly_verts)[3] = MEM_malloc_arrayN(
-      boundary->num_vertices, sizeof(float) * 3, "poly verts");
+      boundary->num_vertices, sizeof(float[3]), "poly verts");
   for (int i = 0; i < boundary->num_vertices; i++) {
     add_v3_v3(boundary->twist.pivot_position, SCULPT_vertex_co_get(ss, boundary->vertices[i]));
     copy_v3_v3(poly_verts[i], SCULPT_vertex_co_get(ss, boundary->vertices[i]));
diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c
index 858c6c4e279..482bdf97d78 100644
--- a/source/blender/editors/sculpt_paint/sculpt_smooth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c
@@ -251,7 +251,7 @@ static void SCULPT_enhance_details_brush(Sculpt *sd,
   if (SCULPT_stroke_is_first_brush_step(ss->cache)) {
     const int totvert = SCULPT_vertex_count_get(ss);
     ss->cache->detail_directions = MEM_malloc_arrayN(
-        totvert, 3 * sizeof(float), "details directions");
+        totvert, sizeof(float[3]), "details directions");
 
     for (int i = 0; i < totvert; i++) {
       float avg[3];
diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc
index 49d5251198a..e5083700d7d 100644
--- a/source/blender/io/usd/intern/usd_capi_import.cc
+++ b/source/blender/io/usd/intern/usd_capi_import.cc
@@ -391,7 +391,7 @@ bool USD_import(struct bContext *C,
   else {
     /* Fake a job context, so that we don't need NULL pointer checks while importing. */
     short stop = 0, do_update = 0;
-    float progress = 0.f;
+    float progress = 0.0f;
 
     import_startjob(job, &stop, &do_update, &progress);
     import_endjob(job);
diff --git a/source/blender/render/intern/texture_margin.cc b/source/blender/render/intern/texture_margin.cc
index adc11cd925e..d01c0dbea71 100644
--- a/source/blender/render/intern/texture_margin.cc
+++ b/source/blender/render/intern/texture_margin.cc
@@ -331,7 +331,7 @@ class TextureMarginMap {
     float destx, desty;
     int foundpoly;
 
-    float mindist = -1.f;
+    float mindist = -1.0f;
 
     /* Loop over all adjacent polygons and determine which edge is closest.
      * This could be optimized by only inspecting neighbors which are on the edge of an island.
@@ -356,7 +356,7 @@ class TextureMarginMap {
       }
     }
 
-    return mindist >= 0.f;
+    return mindist >= 0.0f;
   }
 
   /**



More information about the Bf-blender-cvs mailing list