Cleanup: remove redundant MEM_SAFE_FREE

MEM_SAFE_FREE isn't necessary when the memory is known to be allocated
and clearing the value afterwards isn't necessary.
This commit is contained in:
Campbell Barton 2022-08-11 10:50:51 +10:00
parent 4641d6d7b0
commit d9c2922a14
3 changed files with 17 additions and 18 deletions

View File

@ -337,7 +337,6 @@ static void gpencil_convert_spline(Main *bmain,
/* Add stroke to frame. */
BLI_addtail(&gpf->strokes, gps);
float *coord_array = NULL;
float init_co[3];
switch (nu->type) {
@ -376,8 +375,7 @@ static void gpencil_convert_spline(Main *bmain,
BezTriple *bezt = &nu->bezt[inext];
bool last = (bool)(s == segments - 1);
coord_array = MEM_callocN((size_t)3 * resolu * sizeof(float), __func__);
float *coord_array = MEM_callocN(sizeof(float[3]) * resolu, __func__);
for (int j = 0; j < 3; j++) {
BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
prevbezt->vec[2][j],
@ -397,8 +395,9 @@ static void gpencil_convert_spline(Main *bmain,
gpencil_add_new_points(
gps, coord_array, radius_start, radius_end, init, resolu, init_co, last);
/* Free memory. */
MEM_SAFE_FREE(coord_array);
MEM_freeN(coord_array);
/* As the last point of segment is the first point of next segment, back one array
* element to avoid duplicated points on the same location.
@ -419,7 +418,7 @@ static void gpencil_convert_spline(Main *bmain,
nurb_points = (nu->pntsu - 1) * resolu;
}
/* Get all curve points. */
coord_array = MEM_callocN(sizeof(float[3]) * nurb_points, __func__);
float *coord_array = MEM_callocN(sizeof(float[3]) * nurb_points, __func__);
BKE_nurb_makeCurve(nu, coord_array, NULL, NULL, NULL, resolu, sizeof(float[3]));
/* Allocate memory for storage points. */
@ -429,7 +428,7 @@ static void gpencil_convert_spline(Main *bmain,
/* Add points. */
gpencil_add_new_points(gps, coord_array, 1.0f, 1.0f, 0, gps->totpoints, init_co, false);
MEM_SAFE_FREE(coord_array);
MEM_freeN(coord_array);
}
break;
}

View File

@ -219,8 +219,8 @@ static void phash_delete(PHash *ph)
{
if (ph) {
MEM_SAFE_FREE(ph->buckets);
MEM_freeN(ph);
}
MEM_SAFE_FREE(ph);
}
static int phash_size(PHash *ph)
@ -873,7 +873,7 @@ static int p_connect_pairs(ParamHandle *handle, bool topology_from_uvs)
ncharts++;
}
MEM_SAFE_FREE(stackbase);
MEM_freeN(stackbase);
return ncharts;
}
@ -3495,8 +3495,8 @@ static bool p_chart_convex_hull(PChart *chart, PVert ***r_verts, int *r_nverts,
*r_nverts = npoints;
*r_right = ulen - 1;
MEM_SAFE_FREE(U);
MEM_SAFE_FREE(L);
MEM_freeN(U);
MEM_freeN(L);
return true;
}
@ -3644,8 +3644,8 @@ static float p_chart_minimum_area_angle(PChart *chart)
minangle -= (float)M_PI_2;
}
MEM_SAFE_FREE(angles);
MEM_SAFE_FREE(points);
MEM_freeN(angles);
MEM_freeN(points);
return minangle;
}
@ -3716,7 +3716,7 @@ void GEO_uv_parametrizer_delete(ParamHandle *phandle)
param_assert(ELEM(phandle->state, PHANDLE_STATE_ALLOCATED, PHANDLE_STATE_CONSTRUCTED));
for (int i = 0; i < phandle->ncharts; i++) {
MEM_SAFE_FREE(phandle->charts[i]);
MEM_freeN(phandle->charts[i]);
}
MEM_SAFE_FREE(phandle->charts);
@ -3943,7 +3943,8 @@ void GEO_uv_parametrizer_construct_end(ParamHandle *phandle,
phandle->ncharts = p_connect_pairs(phandle, topology_from_uvs);
phandle->charts = p_split_charts(phandle, chart, phandle->ncharts);
MEM_SAFE_FREE(phandle->construction_chart);
MEM_freeN(phandle->construction_chart);
phandle->construction_chart = nullptr;
phash_delete(phandle->hash_verts);
phash_delete(phandle->hash_edges);
@ -3957,7 +3958,7 @@ void GEO_uv_parametrizer_construct_end(ParamHandle *phandle,
p_chart_boundaries(chart, &outer);
if (!topology_from_uvs && chart->nboundaries == 0) {
MEM_SAFE_FREE(chart);
MEM_freeN(chart);
if (count_fail != NULL) {
*count_fail += 1;
}
@ -4219,7 +4220,7 @@ void GEO_uv_parametrizer_pack(ParamHandle *handle,
p_chart_uv_translate(chart, trans);
p_chart_uv_scale(chart, scale);
}
MEM_SAFE_FREE(boxarray);
MEM_freeN(boxarray);
if (handle->aspx != handle->aspy) {
GEO_uv_parametrizer_scale(handle, handle->aspx, handle->aspy);

View File

@ -215,8 +215,7 @@ static void freeData(ModifierData *md)
MEM_SAFE_FREE(smd->verts[i].binds[j].vert_inds);
MEM_SAFE_FREE(smd->verts[i].binds[j].vert_weights);
}
MEM_SAFE_FREE(smd->verts[i].binds);
MEM_freeN(smd->verts[i].binds);
}
}