[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54058] trunk/blender/source/blender/ editors/physics/particle_edit.c: replace calloc + memcpy with recalloc.

Campbell Barton ideasman42 at gmail.com
Thu Jan 24 01:46:57 CET 2013


Revision: 54058
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54058
Author:   campbellbarton
Date:     2013-01-24 00:46:51 +0000 (Thu, 24 Jan 2013)
Log Message:
-----------
replace calloc + memcpy with recalloc.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/physics/particle_edit.c

Modified: trunk/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_edit.c	2013-01-23 23:42:18 UTC (rev 54057)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c	2013-01-24 00:46:51 UTC (rev 54058)
@@ -3314,22 +3314,15 @@
 		int newtotpart=totpart+n;
 		float hairmat[4][4], cur_co[3];
 		KDTree *tree=0;
-		ParticleData *pa, *new_pars= MEM_callocN(newtotpart*sizeof(ParticleData), "ParticleData new");
-		PTCacheEditPoint *point, *new_points= MEM_callocN(newtotpart*sizeof(PTCacheEditPoint), "PTCacheEditPoint array new");
+		ParticleData *pa;
+		PTCacheEditPoint *point;
 		PTCacheEditKey *key;
 		HairKey *hkey;
 
-		/* save existing elements */
-		memcpy(new_pars, psys->particles, totpart * sizeof(ParticleData));
-		memcpy(new_points, edit->points, totpart * sizeof(PTCacheEditPoint));
-
 		/* change old arrays to new ones */
-		if (psys->particles) MEM_freeN(psys->particles);
-		psys->particles= new_pars;
+		psys->particles = MEM_recallocN(psys->particles, newtotpart * sizeof(ParticleData));
+		edit->points    = MEM_recallocN(edit->points,    newtotpart * sizeof(PTCacheEditPoint));
 
-		if (edit->points) MEM_freeN(edit->points);
-		edit->points= new_points;
-
 		if (edit->mirror_cache) {
 			MEM_freeN(edit->mirror_cache);
 			edit->mirror_cache= NULL;
@@ -3350,8 +3343,8 @@
 		edit->totpoint= psys->totpart= newtotpart;
 
 		/* create new elements */
-		pa= psys->particles + totpart;
-		point= edit->points + totpart;
+		pa = psys->particles + totpart;
+		point = edit->points + totpart;
 
 		for (i=totpart; i<newtotpart; i++, pa++, point++) {
 			memcpy(pa, add_pars + i - totpart, sizeof(ParticleData));




More information about the Bf-blender-cvs mailing list