* [PATCH] ada: Use std::string in print_dynamic_range_bound
@ 2017-10-13 13:46 Simon Marchi
2017-10-13 20:29 ` Yao Qi
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2017-10-13 13:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace this usage of GROW_VECT with an std::string. I don't think
there's a reason for this variable to be static, other than it was
cumbersome to manage its lifetime (i.e. use a cleanup) before.
Tested by comparing the gdb.ada/*.exp test results before and after the
patch.
gdb/ChangeLog:
* ada-typeprint.c (print_dynamic_range_bound): Use std::string.
---
gdb/ada-typeprint.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 2224bb3..0d1f9dc 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -253,15 +253,11 @@ static void
print_dynamic_range_bound (struct type *type, const char *name, int name_len,
const char *suffix, struct ui_file *stream)
{
- static char *name_buf = NULL;
- static size_t name_buf_len = 0;
LONGEST B;
+ std::string name_buf (name, name_len);
+ name_buf += suffix;
- GROW_VECT (name_buf, name_buf_len, name_len + strlen (suffix) + 1);
- strncpy (name_buf, name, name_len);
- strcpy (name_buf + name_len, suffix);
-
- if (get_int_var_value (name_buf, B))
+ if (get_int_var_value (name_buf.c_str (), B))
ada_print_scalar (type, B, stream);
else
fprintf_filtered (stream, "?");
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ada: Use std::string in print_dynamic_range_bound
2017-10-13 13:46 [PATCH] ada: Use std::string in print_dynamic_range_bound Simon Marchi
@ 2017-10-13 20:29 ` Yao Qi
2017-10-14 2:46 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Yao Qi @ 2017-10-13 20:29 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
On 17-10-13 09:45:47, Simon Marchi wrote:
> Replace this usage of GROW_VECT with an std::string. I don't think
> there's a reason for this variable to be static, other than it was
> cumbersome to manage its lifetime (i.e. use a cleanup) before.
>
> Tested by comparing the gdb.ada/*.exp test results before and after the
> patch.
>
> gdb/ChangeLog:
>
> * ada-typeprint.c (print_dynamic_range_bound): Use std::string.
Patch is good to me.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ada: Use std::string in print_dynamic_range_bound
2017-10-13 20:29 ` Yao Qi
@ 2017-10-14 2:46 ` Simon Marchi
0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2017-10-14 2:46 UTC (permalink / raw)
To: Yao Qi; +Cc: Simon Marchi, gdb-patches
On 2017-10-13 16:29, Yao Qi wrote:
> On 17-10-13 09:45:47, Simon Marchi wrote:
>> Replace this usage of GROW_VECT with an std::string. I don't think
>> there's a reason for this variable to be static, other than it was
>> cumbersome to manage its lifetime (i.e. use a cleanup) before.
>>
>> Tested by comparing the gdb.ada/*.exp test results before and after
>> the
>> patch.
>>
>> gdb/ChangeLog:
>>
>> * ada-typeprint.c (print_dynamic_range_bound): Use std::string.
>
> Patch is good to me.
Thanks, pushed.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-14 2:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-13 13:46 [PATCH] ada: Use std::string in print_dynamic_range_bound Simon Marchi
2017-10-13 20:29 ` Yao Qi
2017-10-14 2:46 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox