public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Use std::string in coff-pe-read.c
@ 2022-04-22 15:22 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-04-22 15:22 UTC (permalink / raw)
To: gdb-cvs
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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-22 15:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 15:22 [binutils-gdb] Use std::string in coff-pe-read.c 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).