[Bf-blender-cvs] [bff8ea5] alembic: Fix unfreed motion state memory when freeing strand data.

Lukas Tönne noreply at git.blender.org
Fri Apr 3 12:05:07 CEST 2015


Commit: bff8ea5cd729a3908418049df2b8df524f348279
Author: Lukas Tönne
Date:   Fri Apr 3 12:04:40 2015 +0200
Branches: alembic
https://developer.blender.org/rBbff8ea5cd729a3908418049df2b8df524f348279

Fix unfreed motion state memory when freeing strand data.

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

M	source/blender/blenkernel/BKE_strands.h
M	source/blender/blenkernel/intern/strands.c

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

diff --git a/source/blender/blenkernel/BKE_strands.h b/source/blender/blenkernel/BKE_strands.h
index f720f1b..f45ac0f 100644
--- a/source/blender/blenkernel/BKE_strands.h
+++ b/source/blender/blenkernel/BKE_strands.h
@@ -55,9 +55,10 @@ struct Strands *BKE_strands_new(int strands, int verts);
 void BKE_strands_free(struct Strands *strands);
 
 void BKE_strands_add_motion_state(struct Strands *strands);
-void BKE_strands_state_copy_rest_positions(Strands *strands);
-void BKE_strands_state_copy_root_positions(Strands *strands);
-void BKE_strands_state_clear_velocities(Strands *strands);
+void BKE_strands_remove_motion_state(struct Strands *strands);
+void BKE_strands_state_copy_rest_positions(struct Strands *strands);
+void BKE_strands_state_copy_root_positions(struct Strands *strands);
+void BKE_strands_state_clear_velocities(struct Strands *strands);
 
 void BKE_strands_ensure_normals(struct Strands *strands);
 
diff --git a/source/blender/blenkernel/intern/strands.c b/source/blender/blenkernel/intern/strands.c
index 4cd5b68..5ae2a76 100644
--- a/source/blender/blenkernel/intern/strands.c
+++ b/source/blender/blenkernel/intern/strands.c
@@ -46,6 +46,8 @@ void BKE_strands_free(Strands *strands)
 			MEM_freeN(strands->curves);
 		if (strands->verts)
 			MEM_freeN(strands->verts);
+		if (strands->state)
+			MEM_freeN(strands->state);
 		MEM_freeN(strands);
 	}
 }
@@ -103,6 +105,16 @@ void BKE_strands_add_motion_state(Strands *strands)
 	}
 }
 
+void BKE_strands_remove_motion_state(Strands *strands)
+{
+	if (strands) {
+		if (strands->state) {
+			MEM_freeN(strands->state);
+			strands->state = NULL;
+		}
+	}
+}
+
 static void calc_normals(Strands *strands, bool use_motion_state)
 {
 	StrandIterator it_strand;




More information about the Bf-blender-cvs mailing list