Commit 485cf854 by David Malcolm Committed by David Malcolm

Fix memory leaks in sbitmap.c selftests

"make selftest-valgrind" shows a few leaks in sbitmap.c's selftests;
this patch fixes them.

gcc/ChangeLog:
	* sbitmap.c (selftest::test_set_range): Fix memory leaks.
	(selftest::test_bit_in_range): Likewise.

From-SVN: r256978
parent ef57eeb2
2018-01-23 David Malcolm <dmalcolm@redhat.com>
* sbitmap.c (selftest::test_set_range): Fix memory leaks.
(selftest::test_bit_in_range): Likewise.
2018-01-23 Richard Sandiford <richard.sandiford@linaro.org> 2018-01-23 Richard Sandiford <richard.sandiford@linaro.org>
PR testsuite/83888 PR testsuite/83888
......
...@@ -897,6 +897,7 @@ test_set_range () ...@@ -897,6 +897,7 @@ test_set_range ()
bitmap_set_range (s, 15, 1); bitmap_set_range (s, 15, 1);
ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 1, 14)); ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 1, 14));
ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 15, 15)); ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 15, 15));
sbitmap_free (s);
s = sbitmap_alloc (1024); s = sbitmap_alloc (1024);
bitmap_clear (s); bitmap_clear (s);
...@@ -914,6 +915,7 @@ test_set_range () ...@@ -914,6 +915,7 @@ test_set_range ()
ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 512 + 64, 1023)); ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 512 + 64, 1023));
ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 512, 512)); ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 512, 512));
ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 512 + 63, 512 + 63)); ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 512 + 63, 512 + 63));
sbitmap_free (s);
} }
/* Verify bitmap_bit_in_range_p functions for sbitmap. */ /* Verify bitmap_bit_in_range_p functions for sbitmap. */
...@@ -935,6 +937,8 @@ test_bit_in_range () ...@@ -935,6 +937,8 @@ test_bit_in_range ()
ASSERT_TRUE (bitmap_bit_in_range_p (s, 100, 100)); ASSERT_TRUE (bitmap_bit_in_range_p (s, 100, 100));
ASSERT_TRUE (bitmap_bit_p (s, 100)); ASSERT_TRUE (bitmap_bit_p (s, 100));
sbitmap_free (s);
s = sbitmap_alloc (64); s = sbitmap_alloc (64);
bitmap_clear (s); bitmap_clear (s);
bitmap_set_bit (s, 63); bitmap_set_bit (s, 63);
...@@ -942,6 +946,7 @@ test_bit_in_range () ...@@ -942,6 +946,7 @@ test_bit_in_range ()
ASSERT_TRUE (bitmap_bit_in_range_p (s, 1, 63)); ASSERT_TRUE (bitmap_bit_in_range_p (s, 1, 63));
ASSERT_TRUE (bitmap_bit_in_range_p (s, 63, 63)); ASSERT_TRUE (bitmap_bit_in_range_p (s, 63, 63));
ASSERT_TRUE (bitmap_bit_p (s, 63)); ASSERT_TRUE (bitmap_bit_p (s, 63));
sbitmap_free (s);
s = sbitmap_alloc (1024); s = sbitmap_alloc (1024);
bitmap_clear (s); bitmap_clear (s);
...@@ -985,6 +990,7 @@ test_bit_in_range () ...@@ -985,6 +990,7 @@ test_bit_in_range ()
ASSERT_FALSE (bitmap_bit_in_range_p (s, 17, 31)); ASSERT_FALSE (bitmap_bit_in_range_p (s, 17, 31));
ASSERT_FALSE (bitmap_bit_in_range_p (s, 49, 63)); ASSERT_FALSE (bitmap_bit_in_range_p (s, 49, 63));
ASSERT_FALSE (bitmap_bit_in_range_p (s, 65, 1023)); ASSERT_FALSE (bitmap_bit_in_range_p (s, 65, 1023));
sbitmap_free (s);
} }
/* Run all of the selftests within this file. */ /* Run all of the selftests within this file. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment