[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59038] branches/ soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c : Vertex color transfer: memory leak fix and removing the usage of memory allocation within a loop

Walid Shouman eng.walidshouman at gmail.com
Fri Aug 9 21:56:20 CEST 2013


Revision: 59038
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59038
Author:   walid
Date:     2013-08-09 19:56:20 +0000 (Fri, 09 Aug 2013)
Log Message:
-----------
Vertex color transfer: memory leak fix and removing the usage of memory allocation within a loop

Modified Paths:
--------------
    branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c

Modified: branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c
===================================================================
--- branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c	2013-08-09 19:55:46 UTC (rev 59037)
+++ branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c	2013-08-09 19:56:20 UTC (rev 59038)
@@ -2179,7 +2179,7 @@
 
 				BM_ITER_ELEM (l, &liter, f_dst, BM_LOOPS_OF_FACE) {
 					MLoopCol *lcol = BM_ELEM_CD_GET_VOID_P(l, CD_dst);
-					MLoopCol *lcol_out = MEM_mallocN(sizeof(*lcol_out), "lcol_out bmesh_data_transfer.c");
+					MLoopCol lcol_out;
 
 					if (relative_to_target == true) {
 						zero_v3(v_dst_co);
@@ -2203,28 +2203,28 @@
 					interp_weights_poly_v3(tmp_weight, v_co_list_src, f_src->len, v_dst_co);
 
 					// Interpolating according to the spatially found weights
-					lcol_out->a = 0;
-					lcol_out->b = 0;
-					lcol_out->g = 0;
-					lcol_out->r = 0;
+					lcol_out.a = 0;
+					lcol_out.b = 0;
+					lcol_out.g = 0;
+					lcol_out.r = 0;
 
 					BM_ITER_ELEM_INDEX (l2, &liter2, f_src, BM_LOOPS_OF_FACE, a) {
 						MLoopCol *lcol2 = BM_ELEM_CD_GET_VOID_P(l2, CD_src);
 
 						//there's no madd_v4_v4fl for char!
-						lcol_out->a += (lcol2->a * tmp_weight[a]);
-						lcol_out->b += (lcol2->b * tmp_weight[a]);
-						lcol_out->g += (lcol2->g * tmp_weight[a]);
-						lcol_out->r += (lcol2->r * tmp_weight[a]);
+						lcol_out.a += (lcol2->a * tmp_weight[a]);
+						lcol_out.b += (lcol2->b * tmp_weight[a]);
+						lcol_out.g += (lcol2->g * tmp_weight[a]);
+						lcol_out.r += (lcol2->r * tmp_weight[a]);
 
 					}
 
 					//shall we verify the indices!?
 					//there's no copy_v4_v4 for char!
-					lcol->a = lcol_out->a;
-					lcol->b = lcol_out->b;
-					lcol->g = lcol_out->g;
-					lcol->r = lcol_out->r;
+					lcol->a = lcol_out.a;
+					lcol->b = lcol_out.b;
+					lcol->g = lcol_out.g;
+					lcol->r = lcol_out.r;
 
 					//end of interpolation
 				}
@@ -2283,7 +2283,7 @@
 
 			BM_ITER_ELEM (l, &liter, f_dst, BM_LOOPS_OF_FACE) {
 				MLoopCol *lcol = BM_ELEM_CD_GET_VOID_P(l, CD_dst);
-				MLoopCol *lcol_out = MEM_mallocN(sizeof(*lcol_out), "lcol_out bmesh_data_transfer.c");
+				MLoopCol lcol_out;
 
 				if (relative_to_target == true) {
 					zero_v3(v_dst_co);
@@ -2307,28 +2307,28 @@
 				interp_weights_poly_v3(tmp_weight, v_co_list_src, f_src->len, v_dst_co);
 
 				// Interpolating according to the spatially found weights
-				lcol_out->a = 0;
-				lcol_out->b = 0;
-				lcol_out->g = 0;
-				lcol_out->r = 0;
+				lcol_out.a = 0;
+				lcol_out.b = 0;
+				lcol_out.g = 0;
+				lcol_out.r = 0;
 
 				BM_ITER_ELEM_INDEX (l2, &liter2, f_src, BM_LOOPS_OF_FACE, a) {
 					MLoopCol *lcol2 = BM_ELEM_CD_GET_VOID_P(l2, CD_src);
 
 					//there's no madd_v4_v4fl for char!
-					lcol_out->a += (lcol2->a * tmp_weight[a]);
-					lcol_out->b += (lcol2->b * tmp_weight[a]);
-					lcol_out->g += (lcol2->g * tmp_weight[a]);
-					lcol_out->r += (lcol2->r * tmp_weight[a]);
+					lcol_out.a += (lcol2->a * tmp_weight[a]);
+					lcol_out.b += (lcol2->b * tmp_weight[a]);
+					lcol_out.g += (lcol2->g * tmp_weight[a]);
+					lcol_out.r += (lcol2->r * tmp_weight[a]);
 
 				}
 
 				//shall we verify the indices!?
 				//there's no copy_v4_v4 for char!
-				lcol->a = lcol_out->a;
-				lcol->b = lcol_out->b;
-				lcol->g = lcol_out->g;
-				lcol->r = lcol_out->r;
+				lcol->a = lcol_out.a;
+				lcol->b = lcol_out.b;
+				lcol->g = lcol_out.g;
+				lcol->r = lcol_out.r;
 
 				//end of interpolation
 			}




More information about the Bf-blender-cvs mailing list