[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36632] branches/particles-2010/source/ blender/nodes/texture: Fix for memleaks in texture group nodes.

Lukas Toenne lukas.toenne at googlemail.com
Thu May 12 08:48:45 CEST 2011


Revision: 36632
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36632
Author:   lukastoenne
Date:     2011-05-12 06:48:45 +0000 (Thu, 12 May 2011)
Log Message:
-----------
Fix for memleaks in texture group nodes. Instead of transferring the stack data to the external sockets after group execution, the internal data pointer (TexDelegate) has to be copied, so the delegate can be reused for the next sample. Otherwise the delegate is allocated each time.

Modified Paths:
--------------
    branches/particles-2010/source/blender/nodes/texture/node_texture_tree.c
    branches/particles-2010/source/blender/nodes/texture/nodes/node_texture_common.c

Modified: branches/particles-2010/source/blender/nodes/texture/node_texture_tree.c
===================================================================
--- branches/particles-2010/source/blender/nodes/texture/node_texture_tree.c	2011-05-12 06:34:54 UTC (rev 36631)
+++ branches/particles-2010/source/blender/nodes/texture/node_texture_tree.c	2011-05-12 06:48:45 UTC (rev 36632)
@@ -160,32 +160,6 @@
 		if(exec->threadstack) {
 			tex_free_delegates(exec);
 			
-	#if 0
-	{
-		bNodeThreadStack *nts;
-		bNodeStack *ns;
-		int th, a, i;
-	
-		printf(" --- DEBUG --------\n");
-		for(th=0; th<BLENDER_MAX_THREADS; th++) {
-			printf("Thread %d:\n", th);
-			for(nts=exec->threadstack[th].first, i=0; nts; nts=nts->next, ++i) {
-				printf("\tNode Thread Stack %d:\n", i);
-				for(ns= nts->stack, a=0; a<exec->stacksize; a++, ns++) {
-					printf("\t\tStack %d: ", a);
-					if (ns->is_copy)
-						printf("data=[%p] ", ns->data);
-					else
-						printf("data=%p ", ns->data);
-					if (ns->data && MEM_testN(ns->data))
-						printf("(allocated!)");
-					printf("\n");
-				}
-			}
-		}
-	}
-	#endif
-
 			for(a=0; a<BLENDER_MAX_THREADS; a++) {
 				for(nts=exec->threadstack[a].first; nts; nts=nts->next)
 					if (nts->stack) MEM_freeN(nts->stack);

Modified: branches/particles-2010/source/blender/nodes/texture/nodes/node_texture_common.c
===================================================================
--- branches/particles-2010/source/blender/nodes/texture/nodes/node_texture_common.c	2011-05-12 06:34:54 UTC (rev 36631)
+++ branches/particles-2010/source/blender/nodes/texture/nodes/node_texture_common.c	2011-05-12 06:48:45 UTC (rev 36632)
@@ -53,21 +53,6 @@
 	}
 }
 
-static void move_stack(bNodeStack *to, bNodeStack *from)
-{
-	if (to != from) {
-		copy_v4_v4(to->vec, from->vec);
-		to->data = from->data;
-		to->datatype = from->datatype;
-		to->is_copy = from->is_copy;
-		
-		zero_v4(from->vec);
-		from->data = NULL;
-		from->datatype = 0;
-		from->is_copy = 0;
-	}
-}
-
 /**** GROUP ****/
 
 static void *group_initexec(bNode *node)
@@ -106,7 +91,7 @@
 
 /* Copy internal results to the external outputs.
  */
-static void group_move_outputs(bNode *node, bNodeStack **out, bNodeStack *gstack)
+static void group_copy_outputs(bNode *node, bNodeStack **out, bNodeStack *gstack)
 {
 	bNodeSocket *sock;
 	bNodeStack *ns;
@@ -114,7 +99,7 @@
 	for (sock=node->outputs.first, a=0; sock; sock=sock->next, ++a) {
 		if (sock->groupsock) {
 			ns = node_get_socket_stack(gstack, sock->groupsock);
-			move_stack(out[a], ns);
+			copy_stack(out[a], ns);
 		}
 	}
 }
@@ -137,7 +122,7 @@
 	
 	group_copy_inputs(node, in, nts->stack);
 	ntreeExecThreadNodes(exec, nts, data, thread);
-	group_move_outputs(node, out, nts->stack);
+	group_copy_outputs(node, out, nts->stack);
 	
 	ntreeReleaseThreadStack(nts);
 }




More information about the Bf-blender-cvs mailing list