[Bf-blender-cvs] [a2dbe9f] cloth-improvements: Cleanup: Fix some returns and potential memory leaks

Luca Rood noreply at git.blender.org
Fri Jan 6 00:07:05 CET 2017


Commit: a2dbe9f340dfb16dde8234bea54fc90f94cd61a3
Author: Luca Rood
Date:   Thu Jan 5 00:43:54 2017 -0200
Branches: cloth-improvements
https://developer.blender.org/rBa2dbe9f340dfb16dde8234bea54fc90f94cd61a3

Cleanup: Fix some returns and potential memory leaks

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

M	source/blender/blenkernel/intern/cloth.c

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

diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 7c5d101..70b0359 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -1395,8 +1395,7 @@ BLI_INLINE bool add_shear_bend_spring(ClothModifierData *clmd, LinkNodePair *edg
 	spring = (ClothSpring *)MEM_callocN(sizeof(ClothSpring), "cloth spring");
 
 	if (!spring) {
-		cloth_free_errorsprings(cloth, edgelist);
-		return 0;
+		return false;
 	}
 
 	spring_verts_ordered_set(
@@ -1426,8 +1425,7 @@ BLI_INLINE bool add_shear_bend_spring(ClothModifierData *clmd, LinkNodePair *edg
 	spring = MEM_callocN(sizeof(ClothSpring), "cloth spring");
 
 	if (!spring) {
-		cloth_free_errorsprings(cloth, edgelist);
-		return 0;
+		return false;
 	}
 
 	spring->type = CLOTH_SPRING_TYPE_BENDING;
@@ -1466,7 +1464,7 @@ BLI_INLINE bool add_shear_bend_spring(ClothModifierData *clmd, LinkNodePair *edg
 
 	BLI_linklist_prepend(&cloth->springs, spring);
 
-	return 1;
+	return true;
 }
 
 static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
@@ -1572,6 +1570,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
 							bend_springs++;
 						}
 						else {
+							MEM_freeN(spring_ref);
 							cloth_free_errorsprings(cloth, edgelist);
 							return 0;
 						}
@@ -1583,6 +1582,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
 							bend_springs++;
 						}
 						else {
+							MEM_freeN(spring_ref);
 							cloth_free_errorsprings(cloth, edgelist);
 							return 0;
 						}
@@ -1620,6 +1620,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
 						spring = MEM_callocN(sizeof(ClothSpring), "cloth spring");
 
 						if (!spring) {
+							MEM_freeN(spring_ref);
 							cloth_free_errorsprings(cloth, edgelist);
 							return 0;
 						}




More information about the Bf-blender-cvs mailing list