From 6ca6d29e6b9a9f4f02ac48d8c77030f528ef4325 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 28 Dec 2015 23:19:24 +0100 Subject: [PATCH] Fix memleaks in our gtests. --- source/blender/blenlib/intern/math_statistics.c | 4 +--- tests/gtests/blenlib/BLI_polyfill2d_test.cc | 1 + tests/gtests/blenlib/BLI_stack_test.cc | 2 ++ tests/gtests/bmesh/bmesh_core_test.cc | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/blenlib/intern/math_statistics.c b/source/blender/blenlib/intern/math_statistics.c index bc7a80184aa..784f6904160 100644 --- a/source/blender/blenlib/intern/math_statistics.c +++ b/source/blender/blenlib/intern/math_statistics.c @@ -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); } } diff --git a/tests/gtests/blenlib/BLI_polyfill2d_test.cc b/tests/gtests/blenlib/BLI_polyfill2d_test.cc index 8ca19b11632..a4ed70fbec9 100644 --- a/tests/gtests/blenlib/BLI_polyfill2d_test.cc +++ b/tests/gtests/blenlib/BLI_polyfill2d_test.cc @@ -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); } diff --git a/tests/gtests/blenlib/BLI_stack_test.cc b/tests/gtests/blenlib/BLI_stack_test.cc index 44956a589dc..4c0b95f4b6b 100644 --- a/tests/gtests/blenlib/BLI_stack_test.cc +++ b/tests/gtests/blenlib/BLI_stack_test.cc @@ -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. */ diff --git a/tests/gtests/bmesh/bmesh_core_test.cc b/tests/gtests/bmesh/bmesh_core_test.cc index 9c389a802de..0cbb6ca343e 100644 --- a/tests/gtests/bmesh/bmesh_core_test.cc +++ b/tests/gtests/bmesh/bmesh_core_test.cc @@ -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); }