[Bf-blender-cvs] [4b4bb41] master: Curve: replace calloc with malloc for values immediately written into

Campbell Barton noreply at git.blender.org
Sun Jun 15 06:37:59 CEST 2014


Commit: 4b4bb410e04ee83327171723395005e4c6ecfc32
Author: Campbell Barton
Date:   Sun Jun 15 14:36:33 2014 +1000
https://developer.blender.org/rB4b4bb410e04ee83327171723395005e4c6ecfc32

Curve: replace calloc with malloc for values immediately written into

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

M	source/blender/blenkernel/intern/curve.c
M	source/blender/blenkernel/intern/displist.c
M	source/blender/blenkernel/intern/mball.c

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

diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index f87f686..8bc22b5 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -1676,7 +1676,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
 	}
 	else if (cu->ext2 == 0.0f) {
 		dl = MEM_callocN(sizeof(DispList), "makebevelcurve2");
-		dl->verts = MEM_mallocN(2 * 3 * sizeof(float), "makebevelcurve2");
+		dl->verts = MEM_mallocN(2 * sizeof(float[3]), "makebevelcurve2");
 		BLI_addtail(disp, dl);
 		dl->type = DL_SEGM;
 		dl->parts = 1;
@@ -1693,7 +1693,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
 		nr = 4 + 2 * cu->bevresol;
 
 		dl = MEM_callocN(sizeof(DispList), "makebevelcurve p1");
-		dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p1");
+		dl->verts = MEM_mallocN(nr * sizeof(float[3]), "makebevelcurve p1");
 		BLI_addtail(disp, dl);
 		dl->type = DL_POLY;
 		dl->parts = 1;
@@ -1725,7 +1725,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
 				nr = 3 + 2 * cu->bevresol;
 
 			dl = MEM_callocN(sizeof(DispList), "makebevelcurve p1");
-			dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p1");
+			dl->verts = MEM_mallocN(nr * sizeof(float[3]), "makebevelcurve p1");
 			BLI_addtail(disp, dl);
 			dl->type = DL_SEGM;
 			dl->parts = 1;
@@ -1751,7 +1751,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
 			nr = 2;
 
 			dl = MEM_callocN(sizeof(DispList), "makebevelcurve p2");
-			dl->verts = MEM_callocN(nr * 3 * sizeof(float), "makebevelcurve p2");
+			dl->verts = MEM_mallocN(nr * sizeof(float[3]), "makebevelcurve p2");
 			BLI_addtail(disp, dl);
 			dl->type = DL_SEGM;
 			dl->parts = 1;
@@ -1783,7 +1783,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
 				nr = 3 + 2 * cu->bevresol;
 
 			dl = MEM_callocN(sizeof(DispList), "makebevelcurve p3");
-			dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p3");
+			dl->verts = MEM_mallocN(nr * sizeof(float[3]), "makebevelcurve p3");
 			BLI_addtail(disp, dl);
 			dl->type = DL_SEGM;
 			dl->flag = DL_FRONT_CURVE;
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index afe6a13..7caf3d6 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -347,7 +347,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase,
 
 				dl = MEM_callocN(sizeof(DispList), "makeDispListbez");
 				/* len+1 because of 'forward_diff_bezier' function */
-				dl->verts = MEM_callocN((len + 1) * 3 * sizeof(float), "dlverts");
+				dl->verts = MEM_mallocN((len + 1) * sizeof(float[3]), "dlverts");
 				BLI_addtail(dispbase, dl);
 				dl->parts = 1;
 				dl->nr = len;
@@ -401,7 +401,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase,
 				len = (resolu * SEGMENTSU(nu));
 
 				dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
-				dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts");
+				dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
 				BLI_addtail(dispbase, dl);
 				dl->parts = 1;
 
@@ -418,7 +418,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase,
 			else if (nu->type == CU_POLY) {
 				len = nu->pntsu;
 				dl = MEM_callocN(sizeof(DispList), "makeDispListpoly");
-				dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts");
+				dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
 				BLI_addtail(dispbase, dl);
 				dl->parts = 1;
 				dl->nr = len;
@@ -1227,7 +1227,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
 				len = SEGMENTSU(nu) * resolu;
 
 				dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
-				dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts");
+				dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
 
 				BLI_addtail(dispbase, dl);
 				dl->parts = 1;
@@ -1249,7 +1249,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
 				len = (nu->pntsu * resolu) * (nu->pntsv * resolv);
 
 				dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
-				dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts");
+				dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
 				BLI_addtail(dispbase, dl);
 
 				dl->col = nu->mat_nr;
@@ -1344,7 +1344,7 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp
 	DispList *dl;
 
 	dl = MEM_callocN(sizeof(DispList), "makeDispListbev2");
-	dl->verts = MEM_mallocN(3 * sizeof(float) * dlb->nr, "dlverts");
+	dl->verts = MEM_mallocN(sizeof(float[3]) * dlb->nr, "dlverts");
 	memcpy(dl->verts, prev_fp, 3 * sizeof(float) * dlb->nr);
 
 	dl->type = DL_POLY;
@@ -1626,7 +1626,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
 					if (BLI_listbase_is_empty(&dlbev)) {
 						BevPoint *bevp;
 						dl = MEM_callocN(sizeof(DispList), "makeDispListbev");
-						dl->verts = MEM_callocN(3 * sizeof(float) * bl->nr, "dlverts");
+						dl->verts = MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts");
 						BLI_addtail(dispbase, dl);
 
 						if (bl->poly != -1) dl->type = DL_POLY;
@@ -1682,7 +1682,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
 
 							/* for each part of the bevel use a separate displblock */
 							dl = MEM_callocN(sizeof(DispList), "makeDispListbev1");
-							dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr * steps, "dlverts");
+							dl->verts = data = MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, "dlverts");
 							BLI_addtail(dispbase, dl);
 
 							dl->type = DL_SURF;
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index fc6f914..47aeb18 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -2361,8 +2361,8 @@ void BKE_mball_polygonize(EvaluationContext *eval_ctx, Scene *scene, Object *ob,
 		process.indices = NULL;
 
 		a = process.vertices.count;
-		dl->verts = co = MEM_mallocN(sizeof(float) * 3 * a, "mballverts");
-		dl->nors = no = MEM_mallocN(sizeof(float) * 3 * a, "mballnors");
+		dl->verts = co = MEM_mallocN(sizeof(float[3]) * a, "mballverts");
+		dl->nors = no = MEM_mallocN(sizeof(float[3]) * a, "mballnors");
 
 		for (a = 0; a < process.vertices.count; ptr++, a++, no += 3, co += 3) {
 			copy_v3_v3(co, ptr->co);




More information about the Bf-blender-cvs mailing list