Curve: zero memory on access rather then calloc

also remove redundant check
This commit is contained in:
Campbell Barton
2014-06-19 15:13:15 +10:00
parent 70b8a8daf8
commit 804f58c0de
2 changed files with 7 additions and 9 deletions

View File

@@ -1085,12 +1085,6 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu,
sum = (float *)MEM_callocN(sizeof(float) * len, "makeNurbfaces1");
len = totu * totv;
if (len == 0) {
MEM_freeN(sum);
return;
}
bp = nu->bp;
i = nu->pntsu * nu->pntsv;
ratcomp = 0;
@@ -1193,6 +1187,8 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu,
}
}
zero_v3(in);
/* one! (1.0) real point now */
fp = sum;
for (j = jsta; j <= jen; j++) {
@@ -1307,6 +1303,8 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *
}
}
zero_v3(coord_fp);
/* one! (1.0) real point */
fp = sum;
bp = nu->bp + istart - 1;
@@ -1473,7 +1471,7 @@ float *BKE_curve_surf_make_orco(Object *ob)
}
else {
int size = (nu->pntsu * resolu) * (nu->pntsv * resolv) * 3 * sizeof(float);
float *_tdata = MEM_callocN(size, "temp data");
float *_tdata = MEM_mallocN(size, "temp data");
float *tdata = _tdata;
BKE_nurb_makeFaces(nu, tdata, 0, resolu, resolv);

View File

@@ -397,7 +397,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 * sizeof(float[3]), "dlverts");
dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
BLI_addtail(dispbase, dl);
dl->parts = 1;
@@ -1223,7 +1223,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 * sizeof(float[3]), "dlverts");
dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
BLI_addtail(dispbase, dl);
dl->parts = 1;