Fix memleaks in our gtests.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 28 Dec 2015 22:19:24 +0000 (23:19 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 28 Dec 2015 22:19:24 +0000 (23:19 +0100)
source/blender/blenlib/intern/math_statistics.c
tests/gtests/blenlib/BLI_polyfill2d_test.cc
tests/gtests/blenlib/BLI_stack_test.cc
tests/gtests/bmesh/bmesh_core_test.cc

index bc7a80184aa8827418a37dbaa6b2554c8386f323..784f69041602af4ecf72b3f164c58802718915b7 100644 (file)
@@ -105,8 +105,6 @@ void BLI_covariance_m_vn_ex(
         const int n, const float *cos_vn, const int nbr_cos_vn, const float *center, const bool use_sample_correction,
         float *r_covmat)
 {
-       int i, j, k;
-
        /* Note about that division: see https://en.wikipedia.org/wiki/Bessel%27s_correction.
         * In a nutshell, it must be 1 / (n - 1) for 'sample data', and 1 / n for 'population data'...
         */
@@ -123,7 +121,7 @@ void BLI_covariance_m_vn_ex(
                BLI_task_parallel_range_ex(0, n * n, &data, NULL, 0, covariance_m_vn_ex_task_cb, 0, false);
        }
        else {
-               for (k = 0; k < n * n; k++) {
+               for (int k = 0; k < n * n; k++) {
                        covariance_m_vn_ex_task_cb(&data, NULL, k);
                }
        }
index 8ca19b116324eb8c75abcd68fb231c9b46f49aaa..a4ed70fbec98ef1bbdea9d42aa045157866c937f 100644 (file)
@@ -116,6 +116,7 @@ static void  test_polyfill_topology(
                EXPECT_EQ(true, ELEM((intptr_t)*p, 1, 2));
        }
 
+       BLI_edgehashIterator_free(ehi);
        BLI_edgehash_free(edgehash, NULL);
 }
 
index 44956a589dc61a1c53cff8eb920a0ceb96b0f726..4c0b95f4b6b8b9e22087752ea922dc25e0ee2aeb 100644 (file)
@@ -116,6 +116,8 @@ TEST(stack, Peek)
        }
 
        EXPECT_EQ(BLI_stack_is_empty(stack), true);
+
+       BLI_stack_free(stack);
 }
 
 /* Check that clearing the stack leaves in it a correct state. */
index 9c389a802de4dd5ed55fccbf73c63aa2a9baa66c..0cbb6ca343e48714a0e5eeb7fbc43aa67a0bd19b 100644 (file)
@@ -33,4 +33,5 @@ TEST(bmesh_core, BMVertCreate) {
        EXPECT_FALSE(BM_elem_flag_test((BMElem *)bv3, BM_ELEM_SELECT));
        EXPECT_EQ(1.5f, BM_elem_float_data_get(&bm->vdata, bv3, CD_PROP_FLT));
        EXPECT_EQ(3, BM_mesh_elem_count(bm, BM_VERT));
+       BM_mesh_free(bm);
 }