From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id C56433858435; Wed, 31 Aug 2022 17:14:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C56433858435 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661966095; bh=4W0aIHWtQgFMwJAZYUNK876HY1wUB5GLqJFmIlLzux8=; h=From:To:Subject:Date:From; b=ZdKYa33cGQqlqMlJG+inemmmg0tKONMHAVmBmca80ri3ELCFZkxWcov8FFvoohYWQ E4WM6GKhFOV1u2UbpVb6ulS74KlGwHRTfamULYHjxNkTGF6aHeDddYNnNQn8s7KzoT pdSXtll4+Gmw0/43Mqqb5beE/CcN2FU5K+XbYc08= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Remove a ui-related memory leak X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 4311c583a6ac84e880207bf0418872f407557e60 X-Git-Newrev: b8043d27217ff89abba733476cb71c3656f5722a Message-Id: <20220831171455.C56433858435@sourceware.org> Date: Wed, 31 Aug 2022 17:14:55 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db8043d27217f= f89abba733476cb71c3656f5722a commit b8043d27217ff89abba733476cb71c3656f5722a Author: Tom Tromey Date: Thu Aug 11 13:16:46 2022 -0600 Remove a ui-related memory leak =20 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 =3D current_ui; =20 - /* 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 =3D new pager_file (new stdio_file (ui->outstream)); - gdb_stderr =3D new stderr_file (ui->errstream); - gdb_stdlog =3D new timestamped_file (gdb_stderr); - gdb_stdtarg =3D gdb_stderr; - gdb_stdtargerr =3D 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 =3D new ui (stdin, stdout, stderr); current_ui =3D main_ui; =20 + gdb_stdtarg =3D gdb_stderr; gdb_stdtargerr =3D gdb_stderr; gdb_stdtargin =3D gdb_stdin;