diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2016-11-30 21:46:49 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2016-11-30 21:46:49 -0500 |
commit | 95a23284a3db0ec85bb0b11c70e6b5acf00563f6 (patch) | |
tree | e62c9f38873cbefe0907aa8b6cfe76c91e9f47e4 | |
parent | b9b118c3bb29052ee76c6bf32b99962cda5113ba (diff) | |
download | fsf-binutils-gdb-95a23284a3db0ec85bb0b11c70e6b5acf00563f6.zip fsf-binutils-gdb-95a23284a3db0ec85bb0b11c70e6b5acf00563f6.tar.gz fsf-binutils-gdb-95a23284a3db0ec85bb0b11c70e6b5acf00563f6.tar.bz2 |
Use std::string in ui_out_table
Use std::string for the id field of the ui_out_table object.
I found that all users of ui_out_table_begin passed a non-NULL value to
the tblid parameter, so we don't have to worry about the NULL case. I
changed the tblid parameter to be a std::string while at it.
gdb/ChangeLog:
* ui-out.c (struct ui_out_table) <id>: Change type to
std::string.
(ui_out_table_begin): Change tblid parameter type to
std::string, adapt code.
update following type change.
(clear_table): Update.
(ui_out_new): Update.
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/ui-out.c | 18 |
2 files changed, 17 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e8d03bf..6d535c5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,15 @@ 2016-11-30 Simon Marchi <simon.marchi@polymtl.ca> + * ui-out.c (struct ui_out_table) <id>: Change type to + std::string. + (ui_out_table_begin): Change tblid parameter type to + std::string, adapt code. + update following type change. + (clear_table): Update. + (ui_out_new): Update. + +2016-11-30 Simon Marchi <simon.marchi@polymtl.ca> + * cli-out.h (cli_ui_out_data) <streams>: Change type to std::vector. * cli-out.c: Remove vec.h include. diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 1713183..a40ac0a 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -27,6 +27,7 @@ #include <vector> #include <memory> +#include <string> /* table header structures */ @@ -72,7 +73,7 @@ struct ui_out_table /* String identifying the table (as specified in the table_begin call). */ - char *id; + std::string id; /* Points to the first table header (if any). */ struct ui_out_hdr *header_first; @@ -194,8 +195,7 @@ static void verify_field (struct ui_out *uiout, int *fldno, int *width, static void ui_out_table_begin (struct ui_out *uiout, int nbrofcols, - int nr_rows, - const char *tblid) + int nr_rows, const std::string &tblid) { if (uiout->table.flag) internal_error (__FILE__, __LINE__, @@ -206,13 +206,11 @@ previous table_end.")); uiout->table.body_flag = 0; uiout->table.entry_level = uiout->level + 1; uiout->table.columns = nbrofcols; - if (tblid != NULL) - uiout->table.id = xstrdup (tblid); - else - uiout->table.id = NULL; + uiout->table.id = tblid; + clear_header_list (uiout); - uo_table_begin (uiout, nbrofcols, nr_rows, uiout->table.id); + uo_table_begin (uiout, nbrofcols, nr_rows, uiout->table.id.c_str ()); } void @@ -577,8 +575,7 @@ uo_table_header (struct ui_out *uiout, int width, enum ui_align align, static void clear_table (struct ui_out *uiout) { - xfree (uiout->table.id); - uiout->table.id = NULL; + uiout->table.id.clear (); clear_header_list (uiout); } @@ -875,7 +872,6 @@ ui_out_new (const struct ui_out_impl *impl, void *data, current->field_count = 0; uiout->levels.push_back (std::move (current)); - uiout->table.id = NULL; uiout->table.header_first = NULL; uiout->table.header_last = NULL; uiout->table.header_next = NULL; |