Fix memory leak in BKE_mesh_vert_poly_map_create.

This commit is contained in:
2013-07-16 00:34:03 +00:00
parent 60e64bcfa7
commit e68618a5f2

View File

@@ -2463,10 +2463,11 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
int totvert, int totpoly, int totloop)
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert poly map");
int *indices = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
int *indices, *index_iter;
int i, j;
indices = index_iter = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
/* Count number of polys for each vertex */
for (i = 0; i < totpoly; i++) {
const MPoly *p = &mpoly[i];
@@ -2477,8 +2478,8 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
/* Assign indices mem */
for (i = 0; i < totvert; i++) {
map[i].indices = indices;
indices += map[i].count;
map[i].indices = index_iter;
index_iter += map[i].count;
/* Reset 'count' for use as index in last loop */
map[i].count = 0;