Cleanup: Remove unnecessary size argument to CustomData free function
The size of the data is already known, there's no need to pass it to the type's callback.
This commit is contained in:
@@ -65,6 +65,7 @@ using blender::BitVector;
|
||||
using blender::float2;
|
||||
using blender::ImplicitSharingInfo;
|
||||
using blender::IndexRange;
|
||||
using blender::MutableSpan;
|
||||
using blender::Set;
|
||||
using blender::Span;
|
||||
using blender::StringRef;
|
||||
@@ -138,7 +139,7 @@ struct LayerTypeInfo {
|
||||
* size should be the size of one element of this layer's data (e.g.
|
||||
* LayerTypeInfo.size)
|
||||
*/
|
||||
void (*free)(void *data, int count, int size);
|
||||
void (*free)(void *data, int count);
|
||||
|
||||
/**
|
||||
* a function to interpolate between count source elements of this
|
||||
@@ -224,15 +225,13 @@ static void layerCopy_mdeformvert(const void *source, void *dest, const int coun
|
||||
}
|
||||
}
|
||||
|
||||
static void layerFree_mdeformvert(void *data, const int count, const int size)
|
||||
static void layerFree_mdeformvert(void *data, const int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++) {
|
||||
MDeformVert *dvert = static_cast<MDeformVert *>(POINTER_OFFSET(data, i * size));
|
||||
|
||||
if (dvert->dw) {
|
||||
MEM_freeN(dvert->dw);
|
||||
dvert->dw = nullptr;
|
||||
dvert->totweight = 0;
|
||||
for (MDeformVert &dvert : MutableSpan(static_cast<MDeformVert *>(data), count)) {
|
||||
if (dvert.dw) {
|
||||
MEM_freeN(dvert.dw);
|
||||
dvert.dw = nullptr;
|
||||
dvert.totweight = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -666,21 +665,13 @@ static void layerCopy_mdisps(const void *source, void *dest, const int count)
|
||||
}
|
||||
}
|
||||
|
||||
static void layerFree_mdisps(void *data, const int count, const int /*size*/)
|
||||
static void layerFree_mdisps(void *data, const int count)
|
||||
{
|
||||
MDisps *d = static_cast<MDisps *>(data);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (d[i].disps) {
|
||||
MEM_freeN(d[i].disps);
|
||||
}
|
||||
if (d[i].hidden) {
|
||||
MEM_freeN(d[i].hidden);
|
||||
}
|
||||
d[i].disps = nullptr;
|
||||
d[i].hidden = nullptr;
|
||||
d[i].totdisp = 0;
|
||||
d[i].level = 0;
|
||||
for (MDisps &d : MutableSpan(static_cast<MDisps *>(data), count)) {
|
||||
MEM_SAFE_FREE(d.disps);
|
||||
MEM_SAFE_FREE(d.hidden);
|
||||
d.totdisp = 0;
|
||||
d.level = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -757,10 +748,10 @@ void bpy_bm_generic_invalidate(struct BPy_BMGeneric * /*self*/)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void layerFree_bmesh_elem_py_ptr(void *data, const int count, const int size)
|
||||
static void layerFree_bmesh_elem_py_ptr(void *data, const int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++) {
|
||||
void **ptr = (void **)POINTER_OFFSET(data, i * size);
|
||||
void **ptr = (void **)POINTER_OFFSET(data, i * sizeof(void *));
|
||||
if (*ptr) {
|
||||
bpy_bm_generic_invalidate(static_cast<BPy_BMGeneric *>(*ptr));
|
||||
}
|
||||
@@ -790,13 +781,11 @@ static void layerCopy_grid_paint_mask(const void *source, void *dest, const int
|
||||
}
|
||||
}
|
||||
|
||||
static void layerFree_grid_paint_mask(void *data, const int count, const int /*size*/)
|
||||
static void layerFree_grid_paint_mask(void *data, const int count)
|
||||
{
|
||||
GridPaintMask *gpm = static_cast<GridPaintMask *>(data);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
MEM_SAFE_FREE(gpm[i].data);
|
||||
gpm[i].level = 0;
|
||||
for (GridPaintMask &gpm : MutableSpan(static_cast<GridPaintMask *>(data), count)) {
|
||||
MEM_SAFE_FREE(gpm.data);
|
||||
gpm.level = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2155,7 +2144,7 @@ static void free_layer_data(const eCustomDataType type, const void *data, const
|
||||
{
|
||||
const LayerTypeInfo &type_info = *layerType_getInfo(type);
|
||||
if (type_info.free) {
|
||||
type_info.free(const_cast<void *>(data), totelem, type_info.size);
|
||||
type_info.free(const_cast<void *>(data), totelem);
|
||||
}
|
||||
MEM_freeN(const_cast<void *>(data));
|
||||
}
|
||||
@@ -3364,7 +3353,7 @@ void CustomData_free_elem(CustomData *data, const int index, const int count)
|
||||
size_t offset = size_t(index) * typeInfo->size;
|
||||
BLI_assert(layer_is_mutable(data->layers[i]));
|
||||
|
||||
typeInfo->free(POINTER_OFFSET(data->layers[i].data, offset), count, typeInfo->size);
|
||||
typeInfo->free(POINTER_OFFSET(data->layers[i].data, offset), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3756,7 +3745,7 @@ void CustomData_bmesh_free_block(CustomData *data, void **block)
|
||||
|
||||
if (typeInfo->free) {
|
||||
int offset = data->layers[i].offset;
|
||||
typeInfo->free(POINTER_OFFSET(*block, offset), 1, typeInfo->size);
|
||||
typeInfo->free(POINTER_OFFSET(*block, offset), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3776,7 +3765,7 @@ void CustomData_bmesh_free_block_data(CustomData *data, void *block)
|
||||
const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type));
|
||||
if (typeInfo->free) {
|
||||
const size_t offset = data->layers[i].offset;
|
||||
typeInfo->free(POINTER_OFFSET(block, offset), 1, typeInfo->size);
|
||||
typeInfo->free(POINTER_OFFSET(block, offset), 1);
|
||||
}
|
||||
}
|
||||
if (data->totsize) {
|
||||
@@ -3810,7 +3799,7 @@ void CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data,
|
||||
const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type));
|
||||
const size_t offset = data->layers[i].offset;
|
||||
if (typeInfo->free) {
|
||||
typeInfo->free(POINTER_OFFSET(block, offset), 1, typeInfo->size);
|
||||
typeInfo->free(POINTER_OFFSET(block, offset), 1);
|
||||
}
|
||||
memset(POINTER_OFFSET(block, offset), 0, typeInfo->size);
|
||||
}
|
||||
@@ -4478,7 +4467,7 @@ void CustomData_external_reload(CustomData *data, ID * /*id*/, eCustomDataMask m
|
||||
}
|
||||
else if ((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) {
|
||||
if (typeInfo->free) {
|
||||
typeInfo->free(layer->data, totelem, typeInfo->size);
|
||||
typeInfo->free(layer->data, totelem);
|
||||
}
|
||||
layer->flag &= ~CD_FLAG_IN_MEMORY;
|
||||
}
|
||||
@@ -4653,7 +4642,7 @@ void CustomData_external_write(
|
||||
if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
|
||||
if (free) {
|
||||
if (typeInfo->free) {
|
||||
typeInfo->free(layer->data, totelem, typeInfo->size);
|
||||
typeInfo->free(layer->data, totelem);
|
||||
}
|
||||
layer->flag &= ~CD_FLAG_IN_MEMORY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user