diff options
author | Joel Brobecker <brobecker@adacore.com> | 2020-11-23 21:45:35 -0500 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2020-11-23 21:45:35 -0500 |
commit | 987b670356322ba4d493f441855bf5dc8d946e9f (patch) | |
tree | 50b180ece0ac5d200979b6edefa31fff29cb8adb /gdb/valprint.c | |
parent | 4fbb7ccebe1fdcbae762e8fed6af7a810c81f85c (diff) |
change and rename gmp_string_asprintf to return an std::string
This was suggested by Simon during a code review of this package upstream.
The upside is that this makes the function's API more natural and C++.
The downside is an extra malloc, which might be the reason why we went
for using a unique_xmalloc_ptr in the first place. Since this function
is not expected to be called frequently, the API improvement might be
worth the performance impact.
gdb/ChangeLog:
* gmp-utils.h (gmp_string_printf): Rename from gmp_string_asprintf.
Change return type to std::string. Update all callers.
* gmp-utils.c (gmp_string_printf): Likewise.
Diffstat (limited to 'gdb/valprint.c')
-rw-r--r-- | gdb/valprint.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/valprint.c b/gdb/valprint.c index 38ae0bdf0e..b102ff4b57 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -814,8 +814,8 @@ generic_val_print_fixed_point (struct value *val, struct ui_file *stream, fixed_point_scaling_factor (type)); const char *fmt = TYPE_LENGTH (type) < 4 ? "%.11Fg" : "%.17Fg"; - gdb::unique_xmalloc_ptr<char> str = gmp_string_asprintf (fmt, f.val); - fprintf_filtered (stream, "%s", str.get ()); + std::string str = gmp_string_printf (fmt, f.val); + fprintf_filtered (stream, "%s", str.c_str ()); } } |