[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54108] trunk/blender/source/blender/ editors/physics/particle_edit.c: Revert r54058, caused crash when adding paritcles in particle edit mode
Sergej Reich
sergej.reich at googlemail.com
Sat Jan 26 13:30:47 CET 2013
Revision: 54108
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54108
Author: sergof
Date: 2013-01-26 12:30:44 +0000 (Sat, 26 Jan 2013)
Log Message:
-----------
Revert r54058, caused crash when adding paritcles in particle edit mode
MEM_recallocN() doesn't allocate memory when used on a null pointer.
Just revert commit since there is no real benefit to using
MEM_recallocN() in this case.
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54058
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-26 09:00:20 UTC (rev 54107)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c 2013-01-26 12:30:44 UTC (rev 54108)
@@ -3314,15 +3314,22 @@
int newtotpart=totpart+n;
float hairmat[4][4], cur_co[3];
KDTree *tree=0;
- ParticleData *pa;
- PTCacheEditPoint *point;
+ ParticleData *pa, *new_pars = MEM_callocN(newtotpart*sizeof(ParticleData), "ParticleData new");
+ PTCacheEditPoint *point, *new_points = MEM_callocN(newtotpart*sizeof(PTCacheEditPoint), "PTCacheEditPoint array new");
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 */
- psys->particles = MEM_recallocN(psys->particles, newtotpart * sizeof(ParticleData));
- edit->points = MEM_recallocN(edit->points, newtotpart * sizeof(PTCacheEditPoint));
+ if (psys->particles) MEM_freeN(psys->particles);
+ psys->particles= new_pars;
+ if (edit->points) MEM_freeN(edit->points);
+ edit->points= new_points;
+
if (edit->mirror_cache) {
MEM_freeN(edit->mirror_cache);
edit->mirror_cache= NULL;
More information about the Bf-blender-cvs
mailing list