Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-05-08 17:00:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-05-08 17:00:25 +0400
commit8ac2fee57a12654cfe2dad2f8e7cfd9bd784e84f (patch)
treed984642c4da427e8e6d9463a23a40ae671c2dda8 /source/blender/blenkernel/intern/customdata.c
parent8d0de0c3cfec40aaeba51f541a62674ce64d9e15 (diff)
minor speedup for bmesh - add CustomData_bmesh_free_block_data(), use
when the block would be immediately allocated again.
Diffstat (limited to 'source/blender/blenkernel/intern/customdata.c')
-rw-r--r--source/blender/blenkernel/intern/customdata.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 11c8ca5d3c4..0988af87589 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2422,6 +2422,32 @@ void CustomData_bmesh_free_block(CustomData *data, void **block)
*block = NULL;
}
+/**
+ * Same as #CustomData_bmesh_free_block but zero the memory rather then freeing.
+ */
+void CustomData_bmesh_free_block_data(CustomData *data, void **block)
+{
+ const LayerTypeInfo *typeInfo;
+ int i;
+
+ if (*block == NULL)
+ return;
+
+ for (i = 0; i < data->totlayer; ++i) {
+ if (!(data->layers[i].flag & CD_FLAG_NOFREE)) {
+ typeInfo = layerType_getInfo(data->layers[i].type);
+
+ if (typeInfo->free) {
+ int offset = data->layers[i].offset;
+ typeInfo->free((char *)*block + offset, 1, typeInfo->size);
+ }
+ }
+ }
+
+ if (data->totsize)
+ memset(*block, 0, data->totsize);
+}
+
static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
{