* [PATCH] Fix memory leaks in sbitmap.c selftests
@ 2018-01-22 19:58 David Malcolm
2018-01-23 10:28 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: David Malcolm @ 2018-01-22 19:58 UTC (permalink / raw)
To: gcc-patches; +Cc: David Malcolm
"make selftest-valgrind" shows a few leaks in sbitmap.c's selftests;
this patch fixes them.
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.
OK for trunk?
gcc/ChangeLog:
* sbitmap.c (selftest::test_set_range): Fix memory leaks.
(selftest::test_bit_in_range): Likewise.
---
gcc/sbitmap.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gcc/sbitmap.c b/gcc/sbitmap.c
index cf46cb2..967868a 100644
--- a/gcc/sbitmap.c
+++ b/gcc/sbitmap.c
@@ -897,6 +897,7 @@ test_set_range ()
bitmap_set_range (s, 15, 1);
ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 1, 14));
ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 15, 15));
+ sbitmap_free (s);
s = sbitmap_alloc (1024);
bitmap_clear (s);
@@ -914,6 +915,7 @@ test_set_range ()
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 + 63, 512 + 63));
+ sbitmap_free (s);
}
/* Verify bitmap_bit_in_range_p functions for sbitmap. */
@@ -935,6 +937,8 @@ test_bit_in_range ()
ASSERT_TRUE (bitmap_bit_in_range_p (s, 100, 100));
ASSERT_TRUE (bitmap_bit_p (s, 100));
+ sbitmap_free (s);
+
s = sbitmap_alloc (64);
bitmap_clear (s);
bitmap_set_bit (s, 63);
@@ -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, 63, 63));
ASSERT_TRUE (bitmap_bit_p (s, 63));
+ sbitmap_free (s);
s = sbitmap_alloc (1024);
bitmap_clear (s);
@@ -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, 49, 63));
ASSERT_FALSE (bitmap_bit_in_range_p (s, 65, 1023));
+ sbitmap_free (s);
}
/* Run all of the selftests within this file. */
--
1.8.5.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix memory leaks in sbitmap.c selftests
2018-01-22 19:58 [PATCH] Fix memory leaks in sbitmap.c selftests David Malcolm
@ 2018-01-23 10:28 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2018-01-23 10:28 UTC (permalink / raw)
To: David Malcolm; +Cc: GCC Patches
On Mon, Jan 22, 2018 at 8:51 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> "make selftest-valgrind" shows a few leaks in sbitmap.c's selftests;
> this patch fixes them.
>
> Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.
> OK for trunk?
Ok.
> gcc/ChangeLog:
> * sbitmap.c (selftest::test_set_range): Fix memory leaks.
> (selftest::test_bit_in_range): Likewise.
> ---
> gcc/sbitmap.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/gcc/sbitmap.c b/gcc/sbitmap.c
> index cf46cb2..967868a 100644
> --- a/gcc/sbitmap.c
> +++ b/gcc/sbitmap.c
> @@ -897,6 +897,7 @@ test_set_range ()
> bitmap_set_range (s, 15, 1);
> ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 1, 14));
> ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 15, 15));
> + sbitmap_free (s);
>
> s = sbitmap_alloc (1024);
> bitmap_clear (s);
> @@ -914,6 +915,7 @@ test_set_range ()
> 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 + 63, 512 + 63));
> + sbitmap_free (s);
> }
>
> /* Verify bitmap_bit_in_range_p functions for sbitmap. */
> @@ -935,6 +937,8 @@ test_bit_in_range ()
> ASSERT_TRUE (bitmap_bit_in_range_p (s, 100, 100));
> ASSERT_TRUE (bitmap_bit_p (s, 100));
>
> + sbitmap_free (s);
> +
> s = sbitmap_alloc (64);
> bitmap_clear (s);
> bitmap_set_bit (s, 63);
> @@ -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, 63, 63));
> ASSERT_TRUE (bitmap_bit_p (s, 63));
> + sbitmap_free (s);
>
> s = sbitmap_alloc (1024);
> bitmap_clear (s);
> @@ -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, 49, 63));
> ASSERT_FALSE (bitmap_bit_in_range_p (s, 65, 1023));
> + sbitmap_free (s);
> }
>
> /* Run all of the selftests within this file. */
> --
> 1.8.5.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-23 10:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-22 19:58 [PATCH] Fix memory leaks in sbitmap.c selftests David Malcolm
2018-01-23 10:28 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).