fixed a few of the memory leaks
authorJoseph Eagar <joeedh@gmail.com>
Mon, 18 May 2009 15:53:30 +0000 (15:53 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Mon, 18 May 2009 15:53:30 +0000 (15:53 +0000)
source/blender/blenkernel/intern/editderivedbmesh.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_marking.c
source/blender/editors/mesh/bmeshutils.c

index 42cd76d624f2602cd30825b3ae851f6070f81a5e..3bb8ec0907aa9ffaef1f82dac4b2c9a11a3cf90b 100644 (file)
@@ -171,6 +171,10 @@ void TM_Free(BMEditMesh *em)
        em->act_face = NULL;
 
        if (em->looptris) MEM_freeN(em->looptris);
+
+       if (em->vert_index) MEM_freeN(em->vert_index);
+       if (em->edge_index) MEM_freeN(em->edge_index);
+       if (em->face_index) MEM_freeN(em->face_index);
 }
 
 
index 11fb39fe679aee761102b190a84fea5e8b0d9fbe..fc06148296a60a75ea7ba216f3b6b8864a86acd7 100644 (file)
@@ -475,6 +475,11 @@ BMesh *BM_Copy_Mesh(BMesh *bmold)
                        BM_Copy_Attributes(bmold, bm, loops[i], l);
                }
        }
+       
+       V_FREE(etable);
+       V_FREE(vtable);
+       V_FREE(loops);
+       V_FREE(edges);
 
        return bm;
 }
index c68a9cc5cb5d1093746ab6610f6fc9b38de8b752..358e675a84f6dec36eac179976d590d43e89ba4b 100644 (file)
@@ -60,12 +60,12 @@ void BM_SelectMode_Flush(BMesh *bm)
 
        int totsel;
 
-       if(bm->selectmode & SCE_SELECT_VERTEX){
-               for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm ); e; e= BMIter_Step(&edges)){
+       if(bm->selectmode & SCE_SELECT_VERTEX) {
+               for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm ); e; e= BMIter_Step(&edges)) {
                        if(BM_TestHFlag(e->v1, BM_SELECT) && BM_TestHFlag(e->v2, BM_SELECT)) BM_SetHFlag(e, 1);
                        else BM_ClearHFlag(e, 0);
                }
-               for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)){
+               for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)) {
                        totsel = 0;
                        l=f->loopbase;
                        do{
@@ -81,7 +81,7 @@ void BM_SelectMode_Flush(BMesh *bm)
                }
        }
        else if(bm->selectmode & SCE_SELECT_EDGE) {
-               for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)){
+               for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)) {
                        totsel = 0;
                        l=f->loopbase;
                        do{
@@ -211,11 +211,11 @@ void BM_Select_Face(BMesh *bm, BMFace *f, int select)
 
                BM_ClearHFlag(&(f->head), BM_SELECT);
                l = f->loopbase;
-               do{
+               do {
                        BM_ClearHFlag(&(l->v->head), BM_SELECT);
                        BM_ClearHFlag(&(l->e->head), BM_SELECT);
                        l = ((BMLoop*)(l->head.next));
-               }while(l != f->loopbase);
+               } while(l != f->loopbase);
        }
 }
 
index 53bbbcd8b442c7152b5cfbec71bfd6b49910ab8b..6171967879ebfe30fc9c601309fdda700c975ac0 100644 (file)
@@ -231,6 +231,7 @@ void EDBM_LoadEditBMesh(Scene *scene, Object *ob)
        
        load_editMesh(scene, ob, em);
        free_editMesh(em);
+       MEM_freeN(em);
 }
 
 void EDBM_FreeEditBMesh(BMEditMesh *tm)
@@ -241,6 +242,8 @@ void EDBM_FreeEditBMesh(BMEditMesh *tm)
 
 void EDBM_init_index_arrays(BMEditMesh *tm, int forvert, int foredge, int forface)
 {
+       EDBM_free_index_arrays(tm);
+
        if (forvert) {
                BMIter iter;
                BMVert *ele;