[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50616] trunk/blender/source/blender/ blenkernel/intern/object.c: code cleanup: replace memcpy for copy_v3_v3(), and fix for unlikely crash - if (ob->mat == NULL && ob->totcol)
Campbell Barton
ideasman42 at gmail.com
Sat Sep 15 08:03:50 CEST 2012
Revision: 50616
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50616
Author: campbellbarton
Date: 2012-09-15 06:03:49 +0000 (Sat, 15 Sep 2012)
Log Message:
-----------
code cleanup: replace memcpy for copy_v3_v3(), and fix for unlikely crash - if (ob->mat == NULL && ob->totcol)
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/object.c
Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c 2012-09-15 05:09:42 UTC (rev 50615)
+++ trunk/blender/source/blender/blenkernel/intern/object.c 2012-09-15 06:03:49 UTC (rev 50616)
@@ -305,17 +305,27 @@
ID *id = ob->data;
id->us--;
if (id->us == 0) {
- if (ob->type == OB_MESH) BKE_mesh_unlink(ob->data);
- else if (ob->type == OB_CURVE) BKE_curve_unlink(ob->data);
- else if (ob->type == OB_MBALL) BKE_mball_unlink(ob->data);
+ switch (ob->type) {
+ case OB_MESH:
+ BKE_mesh_unlink((Mesh *)id);
+ break;
+ case OB_CURVE:
+ BKE_curve_unlink((Curve *)id);
+ break;
+ case OB_MBALL:
+ BKE_mball_unlink((MetaBall *)id);
+ break;
+ }
}
ob->data = NULL;
}
-
- for (a = 0; a < ob->totcol; a++) {
- if (ob->mat[a]) ob->mat[a]->id.us--;
+
+ if (ob->mat) {
+ for (a = 0; a < ob->totcol; a++) {
+ if (ob->mat[a]) ob->mat[a]->id.us--;
+ }
+ MEM_freeN(ob->mat);
}
- if (ob->mat) MEM_freeN(ob->mat);
if (ob->matbits) MEM_freeN(ob->matbits);
ob->mat = NULL;
ob->matbits = NULL;
@@ -1757,9 +1767,9 @@
{
BMEditMesh *em;
int a, count;
+
+ zero_v3(vec);
- vec[0] = vec[1] = vec[2] = 0.0f;
-
if (par->type == OB_MESH) {
Mesh *me = par->data;
DerivedMesh *dm;
@@ -1850,7 +1860,7 @@
while (a--) {
if (count == nr) {
found = 1;
- memcpy(vec, bp->vec, sizeof(float) * 3);
+ copy_v3_v3(vec, bp->vec);
break;
}
count++;
@@ -1875,9 +1885,9 @@
while (a--) {
if (count == nr) {
if (co)
- memcpy(vec, co, 3 * sizeof(float));
+ copy_v3_v3(vec, co);
else
- memcpy(vec, bp->vec, 3 * sizeof(float));
+ copy_v3_v3(vec, bp->vec);
break;
}
count++;
More information about the Bf-blender-cvs
mailing list