From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7702 invoked by alias); 2 Nov 2017 22:36:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 7496 invoked by uid 89); 2 Nov 2017 22:36:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Pad, unclean, rfa X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.185.36) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Nov 2017 22:36:20 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 4708D400E50C0 for ; Thu, 2 Nov 2017 17:36:19 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id AO5zemDiDRtUXAO5zey7Nu; Thu, 02 Nov 2017 17:36:19 -0500 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:58978 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eAO5z-003CfJ-34; Thu, 02 Nov 2017 17:36:19 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 13/13] Use std::vector in h8300-tdep.c Date: Thu, 02 Nov 2017 22:36:00 -0000 Message-Id: <20171102223612.3642-14-tom@tromey.com> In-Reply-To: <20171102223612.3642-1-tom@tromey.com> References: <20171102223612.3642-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eAO5z-003CfJ-34 X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya.Home) [71.218.90.63]:58978 X-Source-Auth: tom+tromey.com X-Email-Count: 14 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2017-11/txt/msg00048.txt.bz2 This changes h8300-tdep.c to use std::vector, allowing the removal of a cleanup. gdb/ChangeLog 2017-11-02 Tom Tromey * h8300-tdep.c (h8300_push_dummy_call): Use std::vector. --- gdb/ChangeLog | 4 ++++ gdb/h8300-tdep.c | 16 ++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index 011afcaba4..b9936c0283 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -662,18 +662,16 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argument = 0; argument < nargs; argument++) { - struct cleanup *back_to; struct type *type = value_type (args[argument]); int len = TYPE_LENGTH (type); char *contents = (char *) value_contents (args[argument]); /* Pad the argument appropriately. */ int padded_len = align_up (len, wordsize); - gdb_byte *padded = (gdb_byte *) xmalloc (padded_len); - back_to = make_cleanup (xfree, padded); + std::vector padded (padded_len); - memset (padded, 0, padded_len); - memcpy (len < wordsize ? padded + padded_len - len : padded, + memcpy ((len < wordsize ? padded.data () + padded_len - len + : padded.data ()), contents, len); /* Could the argument fit in the remaining registers? */ @@ -684,7 +682,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (len > wordsize && len % wordsize) { /* I feel so unclean. */ - write_memory (sp + stack_offset, padded, padded_len); + write_memory (sp + stack_offset, padded.data (), padded_len); stack_offset += padded_len; /* That's right --- even though we passed the argument @@ -702,7 +700,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (offset = 0; offset < padded_len; offset += wordsize) { ULONGEST word - = extract_unsigned_integer (padded + offset, + = extract_unsigned_integer (&padded[offset], wordsize, byte_order); regcache_cooked_write_unsigned (regcache, reg++, word); } @@ -711,15 +709,13 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, else { /* It doesn't fit in registers! Onto the stack it goes. */ - write_memory (sp + stack_offset, padded, padded_len); + write_memory (sp + stack_offset, padded.data (), padded_len); stack_offset += padded_len; /* Once one argument has spilled onto the stack, all subsequent arguments go on the stack. */ reg = E_ARGLAST_REGNUM + 1; } - - do_cleanups (back_to); } /* Store return address. */ -- 2.13.6