public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Remove a ui-related memory leak
@ 2022-08-31 17:14 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-08-31 17:14 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b8043d27217ff89abba733476cb71c3656f5722a
commit b8043d27217ff89abba733476cb71c3656f5722a
Author: Tom Tromey <tromey@adacore.com>
Date: Thu Aug 11 13:16:46 2022 -0600
Remove a ui-related memory leak
gdb_setup_readline makes new streams and assigns to the various stream
members of struct ui. However, these assignments cause the previous
values to leak. As far as I can, this code is simply unnecessary and
can be removed -- with the exception of the assignment to gdb_stdtarg,
which is not initialized anywhere else.
Diff:
---
gdb/event-top.c | 11 -----------
gdb/main.c | 1 +
2 files changed, 1 insertion(+), 11 deletions(-)
diff --git a/gdb/event-top.c b/gdb/event-top.c
index a5f24f6a902..1b522a77d79 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -1330,17 +1330,6 @@ gdb_setup_readline (int editing)
{
struct ui *ui = current_ui;
- /* This function is a noop for the sync case. The assumption is
- that the sync setup is ALL done in gdb_init, and we would only
- mess it up here. The sync stuff should really go away over
- time. */
- if (!batch_silent)
- gdb_stdout = new pager_file (new stdio_file (ui->outstream));
- gdb_stderr = new stderr_file (ui->errstream);
- gdb_stdlog = new timestamped_file (gdb_stderr);
- gdb_stdtarg = gdb_stderr;
- gdb_stdtargerr = gdb_stderr;
-
/* If the input stream is connected to a terminal, turn on editing.
However, that is only allowed on the main UI, as we can only have
one instance of readline. */
diff --git a/gdb/main.c b/gdb/main.c
index 91fa1966738..8d2666ecc95 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -676,6 +676,7 @@ captured_main_1 (struct captured_main_args *context)
main_ui = new ui (stdin, stdout, stderr);
current_ui = main_ui;
+ gdb_stdtarg = gdb_stderr;
gdb_stdtargerr = gdb_stderr;
gdb_stdtargin = gdb_stdin;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-31 17:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31 17:14 [binutils-gdb] Remove a ui-related memory leak Tom Tromey
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).