public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Use std::string in coff-pe-read.c
Date: Fri, 22 Apr 2022 15:22:31 +0000 (GMT) [thread overview]
Message-ID: <20220422152231.BDCD33858C2C@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0f34437ba0f5acab1fcb05630d88057402abbfeb
commit 0f34437ba0f5acab1fcb05630d88057402abbfeb
Author: Tom Tromey <tromey@adacore.com>
Date: Tue Apr 19 07:33:09 2022 -0600
Use std::string in coff-pe-read.c
coff-pe-read.c uses xsnprintf and alloca, but using std::string is
better, and just as easy. In general I think alloca is something to
be avoided, and unbounded uses especially so.
Diff:
---
gdb/coff-pe-read.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c
index ae4ca5435b6..5bf0e2dc7f0 100644
--- a/gdb/coff-pe-read.c
+++ b/gdb/coff-pe-read.c
@@ -178,16 +178,13 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
struct bound_minimal_symbol msymbol;
enum minimal_symbol_type msymtype;
int forward_dll_name_len = strlen (forward_dll_name);
- int forward_func_name_len = strlen (forward_func_name);
- int forward_len = forward_dll_name_len + forward_func_name_len + 2;
- char *forward_qualified_name = (char *) alloca (forward_len);
short section;
- xsnprintf (forward_qualified_name, forward_len, "%s!%s", forward_dll_name,
- forward_func_name);
+ std::string forward_qualified_name = string_printf ("%s!%s",
+ forward_dll_name,
+ forward_func_name);
-
- msymbol = lookup_bound_minimal_symbol (forward_qualified_name);
+ msymbol = lookup_bound_minimal_symbol (forward_qualified_name.c_str ());
if (!msymbol.minsym)
{
@@ -195,7 +192,7 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
for (i = 0; i < forward_dll_name_len; i++)
forward_qualified_name[i] = tolower (forward_qualified_name[i]);
- msymbol = lookup_bound_minimal_symbol (forward_qualified_name);
+ msymbol = lookup_bound_minimal_symbol (forward_qualified_name.c_str ());
}
if (!msymbol.minsym)
reply other threads:[~2022-04-22 15:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220422152231.BDCD33858C2C@sourceware.org \
--to=tromey@sourceware.org \
--cc=gdb-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).