diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2016-11-30 21:43:17 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2016-11-30 21:43:17 -0500 |
commit | 4a9d4ea535a6c9b8c2e7cdf91377abe284d0b277 (patch) | |
tree | 04c93d13165e23605d6ba429eff04990fdc3f91f /gdb | |
parent | 56df3084847984aeddd8c24ca997242ec8c5a369 (diff) | |
download | gdb-4a9d4ea535a6c9b8c2e7cdf91377abe284d0b277.zip gdb-4a9d4ea535a6c9b8c2e7cdf91377abe284d0b277.tar.gz gdb-4a9d4ea535a6c9b8c2e7cdf91377abe284d0b277.tar.bz2 |
Use std::vector for mi_ui_out_data::streams
Use a standard vector instead of the home-made version. I used a vector
of plain pointers, because the mi_ui_out_data object doesn't own the
streams objects (i.e. they shouldn't be deleted when the vector is
deleted).
gdb/ChangeLog:
* mi/mi-out.c: Remove vec.h include.
(mi_ui_out_data) <streams>: Change type to std::vector.
(mi_field_string): Update.
(mi_field_fmt): Update.
(mi_flush): Update.
(mi_redirect): Update.
(field_separator): Update.
(mi_open): Update.
(mi_close): Update.
(mi_out_buffered): Update.
(mi_out_rewind): Update.
(mi_out_put): Update.
(mi_out_data_ctor): Update.
(mi_out_data_dtor): Don't free streams.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 17 | ||||
-rw-r--r-- | gdb/mi/mi-out.c | 31 |
2 files changed, 30 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8950f02..e6c7bbd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,22 @@ 2016-11-30 Simon Marchi <simon.marchi@polymtl.ca> + * mi/mi-out.c: Remove vec.h include. + (mi_ui_out_data) <streams>: Change type to std::vector. + (mi_field_string): Update. + (mi_field_fmt): Update. + (mi_flush): Update. + (mi_redirect): Update. + (field_separator): Update. + (mi_open): Update. + (mi_close): Update. + (mi_out_buffered): Update. + (mi_out_rewind): Update. + (mi_out_put): Update. + (mi_out_data_ctor): Update. + (mi_out_data_dtor): Don't free streams. + +2016-11-30 Simon Marchi <simon.marchi@polymtl.ca> + * ui-out.c (ui_out_level_p): Remove typedef. (DEF_VEC_P (ui_out_level_p)): Remove definition. (struct ui_out) <levels>: Change type to vector of unique_ptr of diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index 2561f16..b4da3ba 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -22,17 +22,14 @@ #include "defs.h" #include "ui-out.h" #include "mi-out.h" -#include "vec.h" - -typedef struct ui_file *ui_filep; -DEF_VEC_P (ui_filep); +#include <vector> struct mi_ui_out_data { int suppress_field_separator; int suppress_output; int mi_version; - VEC (ui_filep) *streams; + std::vector<ui_file *> streams; }; typedef struct mi_ui_out_data mi_out_data; @@ -222,7 +219,7 @@ mi_field_string (struct ui_out *uiout, int fldno, int width, if (data->suppress_output) return; - stream = VEC_last (ui_filep, data->streams); + stream = data->streams.back (); field_separator (uiout); if (fldname) fprintf_unfiltered (stream, "%s=", fldname); @@ -245,7 +242,7 @@ mi_field_fmt (struct ui_out *uiout, int fldno, int width, if (data->suppress_output) return; - stream = VEC_last (ui_filep, data->streams); + stream = data->streams.back (); field_separator (uiout); if (fldname) fprintf_unfiltered (stream, "%s=\"", fldname); @@ -280,7 +277,7 @@ void mi_flush (struct ui_out *uiout) { mi_out_data *data = (mi_out_data *) ui_out_data (uiout); - struct ui_file *stream = VEC_last (ui_filep, data->streams); + struct ui_file *stream = data->streams.back (); gdb_flush (stream); } @@ -291,9 +288,9 @@ mi_redirect (struct ui_out *uiout, struct ui_file *outstream) mi_out_data *data = (mi_out_data *) ui_out_data (uiout); if (outstream != NULL) - VEC_safe_push (ui_filep, data->streams, outstream); + data->streams.push_back (outstream); else - VEC_pop (ui_filep, data->streams); + data->streams.pop_back (); return 0; } @@ -306,7 +303,7 @@ static void field_separator (struct ui_out *uiout) { mi_out_data *data = (mi_out_data *) ui_out_data (uiout); - struct ui_file *stream = VEC_last (ui_filep, data->streams); + ui_file *stream = data->streams.back (); if (data->suppress_field_separator) data->suppress_field_separator = 0; @@ -318,7 +315,7 @@ static void mi_open (struct ui_out *uiout, const char *name, enum ui_out_type type) { mi_out_data *data = (mi_out_data *) ui_out_data (uiout); - struct ui_file *stream = VEC_last (ui_filep, data->streams); + ui_file *stream = data->streams.back (); field_separator (uiout); data->suppress_field_separator = 1; @@ -341,7 +338,7 @@ static void mi_close (struct ui_out *uiout, enum ui_out_type type) { mi_out_data *data = (mi_out_data *) ui_out_data (uiout); - struct ui_file *stream = VEC_last (ui_filep, data->streams); + ui_file *stream = data->streams.back (); switch (type) { @@ -363,7 +360,7 @@ void mi_out_rewind (struct ui_out *uiout) { mi_out_data *data = (mi_out_data *) ui_out_data (uiout); - struct ui_file *stream = VEC_last (ui_filep, data->streams); + ui_file *stream = data->streams.back (); ui_file_rewind (stream); } @@ -374,7 +371,7 @@ void mi_out_put (struct ui_out *uiout, struct ui_file *stream) { mi_out_data *data = (mi_out_data *) ui_out_data (uiout); - struct ui_file *outstream = VEC_last (ui_filep, data->streams); + ui_file *outstream = data->streams.back (); ui_file_put (outstream, ui_file_write_for_put, stream); ui_file_rewind (outstream); @@ -397,8 +394,7 @@ mi_out_data_ctor (mi_out_data *self, int mi_version, struct ui_file *stream) { gdb_assert (stream != NULL); - self->streams = NULL; - VEC_safe_push (ui_filep, self->streams, stream); + self->streams.push_back (stream); self->suppress_field_separator = 0; self->suppress_output = 0; @@ -412,7 +408,6 @@ mi_out_data_dtor (struct ui_out *ui_out) { mi_out_data *data = (mi_out_data *) ui_out_data (ui_out); - VEC_free (ui_filep, data->streams); delete data; } |