fix for leak in make_edges_mdata() if there were no edges to create,
authorCampbell Barton <ideasman42@gmail.com>
Sat, 24 Aug 2013 13:13:29 +0000 (13:13 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 24 Aug 2013 13:13:29 +0000 (13:13 +0000)
also reserve the total number of edges in the hash when its created.

source/blender/blenkernel/intern/mesh.c

index 6170e989407e3921a2a3fb8f0b92bd1f55f09e03..64c79713796cadaeb940733f2ce10c7d7cae3e96 100644 (file)
@@ -911,7 +911,7 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll
        MPoly *mpoly;
        MFace *mface;
        MEdge *medge, *med;
-       EdgeHash *hash = BLI_edgehash_new(__func__);
+       EdgeHash *hash;
        struct EdgeSort *edsort, *ed;
        int a, totedge = 0;
        unsigned int totedge_final = 0;
@@ -988,6 +988,7 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll
        MEM_freeN(edsort);
        
        /* set edge members of mloops */
+       hash = BLI_edgehash_new_ex(__func__, totedge_final);
        for (edge_index = 0, med = medge; edge_index < totedge_final; edge_index++, med++) {
                BLI_edgehash_insert(hash, med->v1, med->v2, SET_UINT_IN_POINTER(edge_index));
        }