svn merge ^/trunk/blender -r42617:42655
[blender.git] / source / blender / blenkernel / intern / deform.c
index f7f10276ee49b8eab9072a9998a590b9b8375cd0..5e10fbb70c065c601ded28a3022e77fe3bea6df4 100644 (file)
@@ -45,6 +45,9 @@
 #include "BLI_utildefines.h"
 
 
+#include "BLI_cellalloc.h"
+
+
 void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
 {
        bDeformGroup *defgroup, *defgroupn;
@@ -83,10 +86,10 @@ void defvert_copy(MDeformVert *dvert_dst, const MDeformVert *dvert_src)
        }
        else {
                if (dvert_dst->dw)
-                       MEM_freeN(dvert_dst->dw);
+                       BLI_cellalloc_free(dvert_dst->dw);
 
                if (dvert_src->totweight)
-                       dvert_dst->dw= MEM_dupallocN(dvert_src->dw);
+                       dvert_dst->dw= BLI_cellalloc_dupalloc(dvert_src->dw);
                else
                        dvert_dst->dw= NULL;
 
@@ -584,10 +587,10 @@ 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= BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dvert->totweight+1), "deformWeight");
        if (dvert->dw) {
                memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*dvert->totweight);
-               MEM_freeN(dvert->dw);
+               BLI_cellalloc_free(dvert->dw);
        }
        dvert->dw= dw_new;
        dw_new += dvert->totweight;
@@ -612,10 +615,10 @@ void defvert_add_index_notest(MDeformVert *dvert, int defgroup, const float weig
        if (!dvert || defgroup < 0)
                return;
 
-       dw_new = MEM_callocN(sizeof(MDeformWeight)*(dvert->totweight+1), "defvert_add_to group, new deformWeight");
+       dw_new = BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dvert->totweight+1), "defvert_add_to group, new deformWeight");
        if(dvert->dw) {
                memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*dvert->totweight);
-               MEM_freeN(dvert->dw);
+               BLI_cellalloc_free(dvert->dw);
        }
        dvert->dw = dw_new;
        dw_new += dvert->totweight;
@@ -643,24 +646,24 @@ void defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw)
                 * this deform weight, and reshuffle the others.
                 */
                if (dvert->totweight) {
-                       dw_new = MEM_mallocN(sizeof(MDeformWeight)*(dvert->totweight), __func__);
+                       dw_new = BLI_cellalloc_malloc(sizeof(MDeformWeight)*(dvert->totweight), __func__);
                        if (dvert->dw) {
 #if 1                  /* since we dont care about order, swap this with the last, save a memcpy */
                                if (i != dvert->totweight) {
                                        dvert->dw[i]= dvert->dw[dvert->totweight];
                                }
                                memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
-                               MEM_freeN(dvert->dw);
 #else
                                memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*i);
                                memcpy(dw_new+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i));
 #endif
+                               BLI_cellalloc_free(dvert->dw);
                        }
                        dvert->dw = dw_new;
                }
                else {
                        /* If there are no other deform weights left then just remove this one. */
-                       MEM_freeN(dvert->dw);
+                       BLI_cellalloc_free(dvert->dw);
                        dvert->dw = NULL;
                }
        }