From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 038D73858D37; Wed, 6 Apr 2022 20:22:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 038D73858D37 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] Use new and delete in jit.c X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 6d088eb92ee42e05a4fbe797515229cf2acd0d99 X-Git-Newrev: 8fb105930851c7a722b4794f8348f72f29721cd0 Message-Id: <20220406202226.038D73858D37@sourceware.org> Date: Wed, 6 Apr 2022 20:22:26 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2022 20:22:26 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D8fb105930851= c7a722b4794f8348f72f29721cd0 commit 8fb105930851c7a722b4794f8348f72f29721cd0 Author: Tom Tromey Date: Tue Apr 5 14:43:30 2022 -0600 Use new and delete in jit.c =20 This changes jit.c to use new and delete, rather than XCNEW. This simplifies the code a little. This was useful for another patch I'm working on, and I thought it would make sense to send it separately. =20 Regression tested on x86-64 Fedora 34. Diff: --- gdb/jit.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/gdb/jit.c b/gdb/jit.c index a727143e68b..342b0d07114 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -935,7 +935,7 @@ struct jit_unwind_private { /* Cached register values. See jit_frame_sniffer to see how this works. */ - detached_regcache *regcache; + std::unique_ptr regcache; =20 /* The frame being unwound. */ struct frame_info *this_frame; @@ -1002,10 +1002,7 @@ static void jit_dealloc_cache (struct frame_info *this_frame, void *cache) { struct jit_unwind_private *priv_data =3D (struct jit_unwind_private *) c= ache; - - gdb_assert (priv_data->regcache !=3D NULL); - delete priv_data->regcache; - xfree (priv_data); + delete priv_data; } =20 /* The frame sniffer for the pseudo unwinder. @@ -1035,11 +1032,11 @@ jit_frame_sniffer (const struct frame_unwind *self, =20 gdb_assert (!*cache); =20 - *cache =3D XCNEW (struct jit_unwind_private); - priv_data =3D (struct jit_unwind_private *) *cache; + priv_data =3D new struct jit_unwind_private; + *cache =3D priv_data; /* Take a snapshot of current regcache. */ - priv_data->regcache =3D new detached_regcache (get_frame_arch (this_fram= e), - true); + priv_data->regcache.reset + (new detached_regcache (get_frame_arch (this_frame), true)); priv_data->this_frame =3D this_frame; =20 callbacks.priv_data =3D priv_data; @@ -1072,7 +1069,7 @@ jit_frame_this_id (struct frame_info *this_frame, voi= d **cache, struct gdb_reader_funcs *funcs; struct gdb_unwind_callbacks callbacks; =20 - priv.regcache =3D NULL; + priv.regcache.reset (); priv.this_frame =3D this_frame; =20 /* We don't expect the frame_id function to set any registers, so we