public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: make signal_catch_counts a static array
@ 2020-10-07  3:23 Simon Marchi
  2020-10-07 11:31 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2020-10-07  3:23 UTC (permalink / raw)
  To: gdb-patches

I noticed that signal_catch_counts is a dynamically-allocated array of
constant size, allocated at startup an never freed.  This might as well
be a statically-allocated array.

gdb/ChangeLog:

	* break-catch-sig.c (signal_catch_counts): Make a static arrray.
	(_initialize_break_catch_sig): Don't allocate array.

Change-Id: I220321df5ad6c1d2664ec9d483eea2dc1c979afe
---
 gdb/break-catch-sig.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index e3e6f6fd8c9d..5c7cdf1fecc6 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -60,7 +60,7 @@ static struct breakpoint_ops signal_catchpoint_ops;
 
 /* Count of each signal.  */
 
-static unsigned int *signal_catch_counts;
+static unsigned int signal_catch_counts[GDB_SIGNAL_LAST];
 
 \f
 
@@ -430,8 +430,6 @@ _initialize_break_catch_sig ()
 {
   initialize_signal_catchpoint_ops ();
 
-  signal_catch_counts = XCNEWVEC (unsigned int, GDB_SIGNAL_LAST);
-
   add_catch_command ("signal", _("\
 Catch signals by their names and/or numbers.\n\
 Usage: catch signal [[NAME|NUMBER] [NAME|NUMBER]...|all]\n\
-- 
2.28.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: make signal_catch_counts a static array
  2020-10-07  3:23 [PATCH] gdb: make signal_catch_counts a static array Simon Marchi
@ 2020-10-07 11:31 ` Pedro Alves
  2020-10-07 12:14   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2020-10-07 11:31 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 10/7/20 4:23 AM, Simon Marchi via Gdb-patches wrote:
> I noticed that signal_catch_counts is a dynamically-allocated array of
> constant size, allocated at startup an never freed.  This might as well
> be a statically-allocated array.
> 
> gdb/ChangeLog:
> 
> 	* break-catch-sig.c (signal_catch_counts): Make a static arrray.
> 	(_initialize_break_catch_sig): Don't allocate array.

Looks obviously correct to me.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: make signal_catch_counts a static array
  2020-10-07 11:31 ` Pedro Alves
@ 2020-10-07 12:14   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2020-10-07 12:14 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 2020-10-07 7:31 a.m., Pedro Alves wrote:
> On 10/7/20 4:23 AM, Simon Marchi via Gdb-patches wrote:
>> I noticed that signal_catch_counts is a dynamically-allocated array of
>> constant size, allocated at startup an never freed.  This might as well
>> be a statically-allocated array.
>>
>> gdb/ChangeLog:
>>
>> 	* break-catch-sig.c (signal_catch_counts): Make a static arrray.
>> 	(_initialize_break_catch_sig): Don't allocate array.
> 
> Looks obviously correct to me.

Thanks, I pushed it.

Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-07 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07  3:23 [PATCH] gdb: make signal_catch_counts a static array Simon Marchi
2020-10-07 11:31 ` Pedro Alves
2020-10-07 12:14   ` Simon Marchi

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).