code cleanup: use MEM_mallocN rather then MEM_callocN when the array is
overwritten immediately after.
This commit is contained in:
@@ -158,7 +158,7 @@ static void layerCopy_mdeformvert(const void *source, void *dest,
|
||||
MDeformVert *dvert = (MDeformVert *)((char *)dest + i * size);
|
||||
|
||||
if (dvert->totweight) {
|
||||
MDeformWeight *dw = MEM_callocN(dvert->totweight * sizeof(*dw),
|
||||
MDeformWeight *dw = MEM_mallocN(dvert->totweight * sizeof(*dw),
|
||||
"layerCopy_mdeformvert dw");
|
||||
|
||||
memcpy(dw, dvert->dw, dvert->totweight * sizeof(*dw));
|
||||
@@ -265,7 +265,7 @@ static void layerInterp_mdeformvert(void **sources, const float *weights,
|
||||
if (dvert->dw) MEM_freeN(dvert->dw);
|
||||
|
||||
if (totweight) {
|
||||
dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight,
|
||||
dvert->dw = MEM_mallocN(sizeof(*dvert->dw) * totweight,
|
||||
"layerInterp_mdeformvert dvert->dw");
|
||||
dvert->totweight = totweight;
|
||||
|
||||
|
||||
@@ -735,7 +735,7 @@ MDeformWeight *defvert_verify_index(MDeformVert *dvert, const int defgroup)
|
||||
if (dw_new)
|
||||
return dw_new;
|
||||
|
||||
dw_new = MEM_callocN(sizeof(MDeformWeight) * (dvert->totweight + 1), "deformWeight");
|
||||
dw_new = MEM_mallocN(sizeof(MDeformWeight) * (dvert->totweight + 1), "deformWeight");
|
||||
if (dvert->dw) {
|
||||
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
|
||||
MEM_freeN(dvert->dw);
|
||||
|
||||
@@ -2189,10 +2189,13 @@ static void bm_corners_to_loops_ex(ID *id, CustomData *fdata, CustomData *ldata,
|
||||
if (ld->disps)
|
||||
MEM_freeN(ld->disps);
|
||||
|
||||
ld->disps = MEM_callocN(sizeof(float) * 3 * side * side, "converted loop mdisps");
|
||||
ld->disps = MEM_mallocN(sizeof(float) * 3 * side * side, "converted loop mdisps");
|
||||
if (fd->disps) {
|
||||
memcpy(ld->disps, disps, sizeof(float) * 3 * side * side);
|
||||
}
|
||||
else {
|
||||
memset(ld->disps, 0, sizeof(float) * 3 * side * side);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user