diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-09-10 05:46:52 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-09-10 05:46:52 +0400 |
commit | b0a1904d33a1c097a8e8fd56fe9b3c1d3a34ca55 (patch) | |
tree | 7a89f984f91cc4c20b365219f9de5663122a01ae /source/blender | |
parent | ae446d79e027cf4eb6ea7290ea24c536711249d8 (diff) |
another optimization pass. biggest change is MDeformGroup->dw is now allocated via a somewhat simplistic, if effective allocator. This needs a little bit more work; I'd really prefer building this into guardedalloc, but the method requires mempools, which currently live in blenlib. and I'm not sure if we can have guardedalloc linking with blenlib? anyway, current allocator code is more of a temporary fix until I figure that out.
Diffstat (limited to 'source/blender')
22 files changed, 302 insertions, 35 deletions
diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 32065ea5151..15ef809158b 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -44,6 +44,7 @@ #include "BKE_bmesh.h" #include "BLI_arithb.h" #include "BLI_blenlib.h" +#include "BLI_cellalloc.h" /*split this all into a seperate bevel.c file in src*/ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 7b894d79b45..31ae4d6cbec 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -38,6 +38,7 @@ #include "BLI_arithb.h" #include "BLI_blenlib.h" +#include "BLI_cellalloc.h" #include "DNA_armature_types.h" #include "DNA_action_types.h" diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 9e105b00e15..c3a3f57cd40 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -48,6 +48,7 @@ #include "BKE_pointcache.h" #include "BLI_kdopbvh.h" +#include "BLI_cellalloc.h" #ifdef _WIN32 void tstart ( void ) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index f1420db706f..a9611039dab 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" #include "BLI_editVert.h" +#include "BLI_cellalloc.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 7e67391743a..bda204409b2 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_mempool.h" +#include "BLI_cellalloc.h" #include "DNA_customdata_types.h" #include "DNA_listBase.h" @@ -112,7 +113,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 = BLI_cellalloc_calloc(dvert->totweight * sizeof(*dw), "layerCopy_mdeformvert dw"); memcpy(dw, dvert->dw, dvert->totweight * sizeof(*dw)); @@ -131,7 +132,7 @@ static void layerFree_mdeformvert(void *data, int count, int size) MDeformVert *dvert = (MDeformVert *)((char *)data + i * size); if(dvert->dw) { - MEM_freeN(dvert->dw); + BLI_cellalloc_free(dvert->dw); dvert->dw = NULL; dvert->totweight = 0; } @@ -173,7 +174,7 @@ static void layerInterp_mdeformvert(void **sources, float *weights, /* if this def_nr is not in the list, add it */ if(!node) { - MDeformWeight *tmp_dw = MEM_callocN(sizeof(*tmp_dw), + MDeformWeight *tmp_dw = BLI_cellalloc_calloc(sizeof(*tmp_dw), "layerInterp_mdeformvert tmp_dw"); tmp_dw->def_nr = dw->def_nr; tmp_dw->weight = dw->weight * interp_weight; @@ -184,10 +185,10 @@ static void layerInterp_mdeformvert(void **sources, float *weights, } /* now we know how many unique deform weights there are, so realloc */ - if(dvert->dw) MEM_freeN(dvert->dw); + if(dvert->dw) BLI_cellalloc_free(dvert->dw); if(totweight) { - dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight, + dvert->dw = BLI_cellalloc_calloc(sizeof(*dvert->dw) * totweight, "layerInterp_mdeformvert dvert->dw"); dvert->totweight = totweight; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 47736865273..9ad004cff5f 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -60,6 +60,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" +#include "BLI_cellalloc.h" #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/source/blender/blenkernel/intern/editderivedbmesh.c b/source/blender/blenkernel/intern/editderivedbmesh.c index d6f31847ca5..b9f81911518 100644 --- a/source/blender/blenkernel/intern/editderivedbmesh.c +++ b/source/blender/blenkernel/intern/editderivedbmesh.c @@ -132,6 +132,45 @@ static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm) if (tm->looptris) MEM_freeN(tm->looptris); +#if 0 //simple quad/triangle code for performance testing purposes + looptris = MEM_callocN(sizeof(void*)*bm->totface*8, "looptris"); + + f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); + for ( ; f; f=BMIter_Step(&iter)) { + EditVert *v, *lastv=NULL, *firstv=NULL; + EditEdge *e; + EditFace *efa; + + /*don't consider two-edged faces*/ + if (f->len < 3) continue; + + //V_GROW(looptris); + //V_GROW(looptris); + //V_GROW(looptris); + + looptris[i*3] = f->loopbase; + looptris[i*3+1] = f->loopbase->head.next; + looptris[i*3+2] = f->loopbase->head.next->next; + i++; + + if (f->len > 3) { + //V_GROW(looptris); + //V_GROW(looptris); + //V_GROW(looptris); + + looptris[i*3] = f->loopbase; + looptris[i*3+1] = f->loopbase->head.next->next; + looptris[i*3+2] = f->loopbase->head.next->next->next; + i++; + } + + } + + tm->tottri = i; + tm->looptris = looptris; + return; +#endif + f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); for ( ; f; f=BMIter_Step(&iter)) { EditVert *v, *lastv=NULL, *firstv=NULL; @@ -360,7 +399,7 @@ static void bmDM_recalcTesselation(DerivedMesh *dm) { EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; - bmdm_recalc_lookups(bmdm); + //bmdm_recalc_lookups(bmdm); } static void bmDM_foreachMappedVert(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no_f, short *no_s), void *userData) @@ -1463,9 +1502,9 @@ static void bmDM_release(void *dm) MEM_freeN(bmdm->faceNos); } - BLI_ghash_free(bmdm->fhash, NULL, NULL); - BLI_ghash_free(bmdm->ehash, NULL, NULL); - BLI_ghash_free(bmdm->vhash, NULL, NULL); + if (bmdm->fhash) BLI_ghash_free(bmdm->fhash, NULL, NULL); + if (bmdm->ehash) BLI_ghash_free(bmdm->ehash, NULL, NULL); + if (bmdm->vhash) BLI_ghash_free(bmdm->vhash, NULL, NULL); if (bmdm->vtable) MEM_freeN(bmdm->vtable); if (bmdm->etable) MEM_freeN(bmdm->etable); @@ -1630,7 +1669,7 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em, Object *ob, } } - bmdm_recalc_lookups(bmdm); + //bmdm_recalc_lookups(bmdm); return (DerivedMesh*) bmdm; } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index a2fa97cabc9..4ba1c46d0c3 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -58,6 +58,7 @@ #include "BKE_utildefines.h" #include "BLI_blenlib.h" +#include "BLI_cellalloc.h" #ifdef HAVE_CONFIG_H diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 67d63d527cb..70d76d25e93 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" +#include "BLI_cellalloc.h" #include "DNA_armature_types.h" #include "DNA_mesh_types.h" diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 4448b690af9..617eb370e9f 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -246,7 +246,7 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount) for (i=0; i<copycount; i++){ if (src[i].dw){ - dst[i].dw = MEM_callocN (sizeof(MDeformWeight)*src[i].totweight, "copy_deformWeight"); + dst[i].dw = BLI_cellalloc_calloc (sizeof(MDeformWeight)*src[i].totweight, "copy_deformWeight"); memcpy (dst[i].dw, src[i].dw, sizeof (MDeformWeight)*src[i].totweight); } } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 2e4146437a2..d796b5b36b1 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -50,6 +50,7 @@ #include "BLI_edgehash.h" #include "BLI_ghash.h" #include "BLI_memarena.h" +#include "BLI_cellalloc.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 36b661e3b1c..d281fb9bd2a 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -45,6 +45,7 @@ #include "BLI_edgehash.h" #include "BLI_ghash.h" #include "BLI_memarena.h" +#include "BLI_cellalloc.h" #include "MEM_guardedalloc.h" @@ -288,7 +289,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, int numVerts, numEdges, numFaces; int maxVerts, maxEdges, maxFaces; int finalVerts, finalEdges, finalFaces; - int *indexMap; + int *indexMap = NULL; DerivedMesh *result, *start_cap = NULL, *end_cap = NULL; MVert *src_mvert; @@ -406,7 +407,6 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, #define _E(s, i) ((BMVert**)(s)->data.buf)[i] -#if 0 /*calculate merge mapping*/ if (j == 0) { BMOperator findop; @@ -444,20 +444,19 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, BMO_Finish_Op(em->bm, &findop); } -#endif /*generate merge mappping using index map. we do this by using the operator slots as lookup arrays.*/ #define E(i) (i) < s1->len ? _E(s1, i) : _E(s2, (i)-s1->len) - /*for (i=0; i<indexLen; i++) { + for (i=0; i<indexLen; i++) { if (!indexMap[i]) continue; v = E(i); v2 = E(indexMap[i]-1); BMO_Insert_MapPointer(em->bm, &weldop, "targetmap", v, v2); - }*/ + } #undef E #undef _E @@ -477,7 +476,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, cddm = CDDM_from_BMEditMesh(em, NULL); BMEdit_Free(em); - //MEM_freeN(indexMap); + MEM_freeN(indexMap); return cddm; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 3d895c37884..9aaff82de84 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -56,6 +56,7 @@ #include "BLI_linklist.h" #include "BLI_rand.h" #include "BLI_threads.h" +#include "BLI_cellalloc.h" #include "BKE_anim.h" diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index aeadbb05cb1..094ea37afff 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -70,6 +70,7 @@ variables on the UI for now #include "BLI_arithb.h" #include "BLI_ghash.h" #include "BLI_threads.h" +#include "BLI_cellalloc.h" #include "BKE_curve.h" #include "BKE_effect.h" diff --git a/source/blender/blenlib/BLI_cellalloc.h b/source/blender/blenlib/BLI_cellalloc.h new file mode 100644 index 00000000000..0e6310ef0b4 --- /dev/null +++ b/source/blender/blenlib/BLI_cellalloc.h @@ -0,0 +1,43 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 by Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/* + Simple, fast memory allocator that uses many BLI_mempools for allocation. + use for allocations < 1024 bytes that simply cannot be rewritten to use + mempools directly or memarenas. + + Should really become part of guardedalloc, but I'm not sure how to + get it linking with blenlib on all build systems. - joeedh +*/ + +void *BLI_cellalloc_malloc(long size, char *tag); +void *BLI_cellalloc_calloc(long size, char *tag); +void BLI_cellalloc_free(void *mem); +void BLI_cellalloc_printleaks(void); +int BLI_cellalloc_get_totblock(void); +void BLI_cellalloc_destroy(void); diff --git a/source/blender/blenlib/intern/BLI_cellalloc.c b/source/blender/blenlib/intern/BLI_cellalloc.c new file mode 100644 index 00000000000..85ef34900c9 --- /dev/null +++ b/source/blender/blenlib/intern/BLI_cellalloc.c @@ -0,0 +1,151 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 by Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Joseph Eagar + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/* + Simple, fast memory allocator that uses many BLI_mempools for allocation. + this is meant to be used by lots of relatively small objects. +*/ + +#include "MEM_guardedalloc.h" + +#include "BKE_utildefines.h" + +#include "BLI_blenlib.h" +#include "BLI_linklist.h" + +#include "DNA_listBase.h" +#include "BLI_mempool.h" + +#include <string.h> + +static BLI_mempool **pools; +static int totpool = 0; +ListBase active_mem = {NULL, NULL}; +static int celltotblock = 0; + +#define MEMIDCHECK ('a' | ('b' << 4) | ('c' << 8) | ('d' << 12)) + +typedef struct MemHeader { + struct MemHeader *next, *prev; + + int size; + char *tag; + int idcheck; +} MemHeader; + +void *BLI_cellalloc_malloc(long size, char *tag) +{ + MemHeader *memh; + int slot = size + sizeof(MemHeader); + + if (!slot) + return NULL; + + if (slot >= totpool) { + void *tmp; + + tmp = calloc(1, sizeof(void*)*(slot+1)); + if (pools) { + memcpy(tmp, pools, totpool*sizeof(void*)); + } + + pools = tmp; + totpool = slot+1; + } + + if (!pools[slot]) { + pools[slot] = BLI_mempool_create(slot, 1, 128); + } + + memh = BLI_mempool_alloc(pools[slot]); + memh->size = size; + memh->idcheck = MEMIDCHECK; + memh->tag = tag; + BLI_addtail(&active_mem, memh); + celltotblock++; + + return memh + 1; +} + +void *BLI_cellalloc_calloc(long size, char *tag) +{ + void *mem = BLI_cellalloc_malloc(size, tag); + BMEMSET(mem, 0, size); + + return mem; +} + +void BLI_cellalloc_free(void *mem) +{ + MemHeader *memh = mem; + + if (!memh) + return; + + memh--; + if (memh->idcheck != MEMIDCHECK) { + printf("Error in BLI_cellalloc: attempt to free invalid block.\n"); + return; + } + + if (memh->size > 0 && memh->size+sizeof(MemHeader) < totpool) { + BLI_remlink(&active_mem, memh); + BLI_mempool_free(pools[memh->size+sizeof(MemHeader)], memh); + celltotblock--; + } else { + printf("Error in BLI_cellalloc: attempt to free corrupted block.\n"); + } +} + +void BLI_cellalloc_printleaks(void) +{ + MemHeader *memh; + + if (!active_mem.first) return; + + for (memh=active_mem.first; memh; memh=memh->next) { + printf("%s %d %p\n", memh->tag, memh->size, memh+1); + } +} + +int BLI_cellalloc_get_totblock(void) +{ + return celltotblock; +} + +void BLI_cellalloc_destroy(void) +{ + int i; + + for (i=0; i<totpool; i++) { + if (pools[i]) { + BLI_mempool_destroy(pools[i]); + pools[i] = NULL; + } + } +}
\ No newline at end of file diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index b0c916db357..c553e95ff44 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Geoffery Bantle * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1be2f074813..3ed39f2611d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -107,6 +107,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" #include "BLI_storage_types.h" // for relname flags +#include "BLI_cellalloc.h" #include "BKE_animsys.h" #include "BKE_action.h" diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index c4e92c64492..ed2c2f20789 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -188,16 +188,19 @@ void BM_Compute_Normals(BMesh *bm) BMVert *v; BMFace *f; BMLoop *l; - BMIter verts; BMIter faces; BMIter loops; - unsigned int maxlength = 0; float (*projectverts)[3]; + //return; + /*first, find out the largest face in mesh*/ for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f = BMIter_Step(&faces)){ + if (BM_TestHFlag(f, BM_HIDDEN)) + continue; + if(f->len > maxlength) maxlength = f->len; } @@ -209,22 +212,36 @@ void BM_Compute_Normals(BMesh *bm) /*calculate all face normals*/ for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f = BMIter_Step(&faces)){ - if (f->head.flag & BM_NONORMCALC) continue; + if (BM_TestHFlag(f, BM_HIDDEN)) + continue; + if (f->head.flag & BM_NONORMCALC) + continue; + bmesh_update_face_normal(bm, f, projectverts); } /*Zero out vertex normals*/ - for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm ); v; v = BMIter_Step(&verts)) + for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm ); v; v = BMIter_Step(&verts)) { + if (BM_TestHFlag(v, BM_HIDDEN)) + continue; + v->no[0] = v->no[1] = v->no[2] = 0.0; + } /*add face normals to vertices*/ for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f = BMIter_Step(&faces)){ + if (BM_TestHFlag(f, BM_HIDDEN)) + continue; + for(l = BMIter_New(&loops, bm, BM_LOOPS_OF_FACE, f ); l; l = BMIter_Step(&loops)) VecAddf(l->v->no, l->v->no, f->no); } /*average the vertex normals*/ for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm ); v; v= BMIter_Step(&verts)){ + if (BM_TestHFlag(v, BM_HIDDEN)) + continue; + if (Normalize(v->no)==0.0) { VECCOPY(v->no, v->co); Normalize(v->no); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 154ab14df60..789cfaa840d 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -47,6 +47,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BLI_cellalloc.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -185,10 +186,10 @@ MDeformWeight *verify_defweight (MDeformVert *dv, int defgroup) if (newdw) return newdw; - newdw = MEM_callocN (sizeof(MDeformWeight)*(dv->totweight+1), "deformWeight"); + newdw = BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dv->totweight+1), "deformWeight"); if (dv->dw){ memcpy (newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight); - MEM_freeN (dv->dw); + BLI_cellalloc_free (dv->dw); } dv->dw=newdw; @@ -577,13 +578,13 @@ void remove_vert_def_nr (Object *ob, int def_nr, int vertnum) * deform weight, and reshuffle the others */ if (dvert->totweight) { - newdw = MEM_mallocN (sizeof(MDeformWeight)*(dvert->totweight), + newdw = BLI_cellalloc_malloc (sizeof(MDeformWeight)*(dvert->totweight), "deformWeight"); if (dvert->dw){ memcpy (newdw, dvert->dw, sizeof(MDeformWeight)*i); memcpy (newdw+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i)); - MEM_freeN (dvert->dw); + BLI_cellalloc_free (dvert->dw); } dvert->dw=newdw; } @@ -591,7 +592,7 @@ void remove_vert_def_nr (Object *ob, int def_nr, int vertnum) * left then just remove the deform weight */ else { - MEM_freeN (dvert->dw); + BLI_cellalloc_free (dvert->dw); dvert->dw = NULL; break; } @@ -677,11 +678,11 @@ void add_vert_defnr (Object *ob, int def_nr, int vertnum, /* if we are doing an additive assignment, then * we need to create the deform weight */ - newdw = MEM_callocN (sizeof(MDeformWeight)*(dv->totweight+1), + newdw = BLI_cellalloc_calloc (sizeof(MDeformWeight)*(dv->totweight+1), "deformWeight"); if (dv->dw){ memcpy (newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight); - MEM_freeN (dv->dw); + BLI_cellalloc_free (dv->dw); } dv->dw=newdw; @@ -772,10 +773,10 @@ void assign_verts_defgroup (Object *ob, float weight) } /* If not: Add the group and set its weight */ if (!done){ - newdw = MEM_callocN (sizeof(MDeformWeight)*(dvert->totweight+1), "deformWeight"); + newdw = BLI_cellalloc_calloc (sizeof(MDeformWeight)*(dvert->totweight+1), "deformWeight"); if (dvert->dw){ memcpy (newdw, dvert->dw, sizeof(MDeformWeight)*dvert->totweight); - MEM_freeN (dvert->dw); + BLI_cellalloc_free (dvert->dw); } dvert->dw=newdw; @@ -918,7 +919,7 @@ void remove_verts_defgroup (Object *ob, int allverts) if (eg == dg){ dvert->totweight--; if (dvert->totweight){ - newdw = MEM_mallocN (sizeof(MDeformWeight)*(dvert->totweight), "deformWeight"); + newdw = BLI_cellalloc_malloc (sizeof(MDeformWeight)*(dvert->totweight), "deformWeight"); if (dvert->dw){ memcpy (newdw, dvert->dw, sizeof(MDeformWeight)*i); @@ -928,7 +929,7 @@ void remove_verts_defgroup (Object *ob, int allverts) dvert->dw=newdw; } else{ - MEM_freeN (dvert->dw); + BLI_cellalloc_free (dvert->dw); dvert->dw=NULL; break; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 2d44969aaf2..001349b4362 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -44,6 +44,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" #include "BLI_memarena.h" +#include "BLI_cellalloc.h" #include "MTC_matrixops.h" #include "DNA_action_types.h" diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 9a268f8be17..d05bc07ce95 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -55,6 +55,7 @@ #include "BKE_packedFile.h" #include "BLI_blenlib.h" +#include "BLI_cellalloc.h" #include "RE_pipeline.h" /* RE_ free stuff */ @@ -268,8 +269,11 @@ void WM_exit(bContext *C) SYS_DeleteSystem(SYS_GetSystem()); - if(MEM_get_memory_blocks_in_use()!=0) { - printf("Error Totblock: %d\n", MEM_get_memory_blocks_in_use()); + if(MEM_get_memory_blocks_in_use()!=0 || BLI_cellalloc_get_totblock()!=0) { + printf("Error Totblock: %d\n", + BLI_cellalloc_get_totblock()+MEM_get_memory_blocks_in_use()); + BLI_cellalloc_printleaks(); + BLI_cellalloc_destroy(); MEM_printmemlist(); } // delete_autosave(); |