fix for memory leak in BKE_mesh_ensure_navmesh(), it would add 2 navmesh layers,...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 3 Jul 2012 08:16:14 +0000 (08:16 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 3 Jul 2012 08:16:14 +0000 (08:16 +0000)
source/blender/blenkernel/intern/mesh.c

index e3b13ca0f1746eaff145c543d5b9a148d9798cb6..6d47575b37244cc10976f4c4c9d42d0b63cb4c19 100644 (file)
@@ -3146,19 +3146,17 @@ void BKE_mesh_translate(Mesh *me, float offset[3], int do_keys)
        }
 }
 
-
 void BKE_mesh_ensure_navmesh(Mesh *me)
 {
        if (!CustomData_has_layer(&me->pdata, CD_RECAST)) {
                int i;
                int numFaces = me->totpoly;
                int *recastData;
-               CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_CALLOC, NULL, numFaces, "recastData");
-               recastData = (int *)CustomData_get_layer(&me->pdata, CD_RECAST);
+               recastData = (int *)MEM_mallocN(numFaces * sizeof(int), __func__);
                for (i = 0; i < numFaces; i++) {
                        recastData[i] = i + 1;
                }
-               CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_REFERENCE, recastData, numFaces, "recastData");
+               CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_ASSIGN, recastData, numFaces, "recastData");
        }
 }