From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106430 invoked by alias); 24 Nov 2016 15:28:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 106308 invoked by uid 89); 24 Nov 2016 15:28:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.4 required=5.0 tests=AWL,BAYES_50,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=Hx-spam-relays-external:sk:cable-1, H*RU:sk:cable-1, H*r:sk:cable-1, uiout X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Nov 2016 15:28:03 +0000 X-ASG-Debug-ID: 1480001281-0c856e65d4b89750001-fS2M51 Received: from smtp.electronicbox.net (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id hLVbxYqsnyHutFLz (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 24 Nov 2016 10:28:01 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (cable-11.246.173-162.electronicbox.net [173.246.11.162]) by smtp.electronicbox.net (Postfix) with ESMTP id 6E7CA440E7C; Thu, 24 Nov 2016 10:28:01 -0500 (EST) From: Simon Marchi X-Barracuda-Effective-Source-IP: cable-11.246.173-162.electronicbox.net[173.246.11.162] X-Barracuda-Apparent-Source-IP: 173.246.11.162 X-Barracuda-RBL-IP: 173.246.11.162 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 11/22] Use std::vector for cli_ui_out_data::streams Date: Thu, 24 Nov 2016 15:28:00 -0000 X-ASG-Orig-Subj: [PATCH 11/22] Use std::vector for cli_ui_out_data::streams Message-Id: <20161124152710.25007-11-simon.marchi@polymtl.ca> In-Reply-To: <20161124152428.24725-1-simon.marchi@polymtl.ca> References: <20161124152428.24725-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1480001281 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 4891 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_SC0_MISMATCH_TO X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.34709 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00759.txt.bz2 Use a standard vector instead of the home-made version. I used a vector of plain pointers, because the cli_ui_out_data object doesn't own the streams objects (i.e. they shouldn't be deleted when the vector is deleted). gdb/ChangeLog: * cli-out.h (cli_ui_out_data) : Change type to std::vector. * cli-out.c (cli_uiout_dtor): Update. (cli_field_fmt): Update. (cli_spaces): Update. (cli_text): Update. (cli_message): Update. (cli_flush): Update. (cli_redirect): Update. (out_field_fmt): Update. (field_separator): Update. (cli_out_data_ctor): Update. (cli_out_new): Update. (cli_out_set_stream): Update. --- gdb/cli-out.c | 31 +++++++++++++++---------------- gdb/cli-out.h | 9 ++------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/gdb/cli-out.c b/gdb/cli-out.c index b98af4a..83da5ac 100644 --- a/gdb/cli-out.c +++ b/gdb/cli-out.c @@ -46,7 +46,6 @@ cli_uiout_dtor (struct ui_out *ui_out) { cli_out_data *data = (cli_out_data *) ui_out_data (ui_out); - VEC_free (ui_filep, data->streams); delete data; } @@ -239,7 +238,7 @@ cli_field_fmt (struct ui_out *uiout, int fldno, if (data->suppress_output) return; - stream = VEC_last (ui_filep, data->streams); + stream = data->streams.back (); vfprintf_filtered (stream, format, args); if (align != ui_noalign) @@ -255,7 +254,7 @@ cli_spaces (struct ui_out *uiout, int numspaces) if (data->suppress_output) return; - stream = VEC_last (ui_filep, data->streams); + stream = data->streams.back (); print_spaces_filtered (numspaces, stream); } @@ -268,7 +267,7 @@ cli_text (struct ui_out *uiout, const char *string) if (data->suppress_output) return; - stream = VEC_last (ui_filep, data->streams); + stream = data->streams.back (); fputs_filtered (string, stream); } @@ -280,7 +279,7 @@ cli_message (struct ui_out *uiout, const char *format, va_list args) if (data->suppress_output) return; - struct ui_file *stream = VEC_last (ui_filep, data->streams); + struct ui_file *stream = data->streams.back (); vfprintf_unfiltered (stream, format, args); } @@ -298,7 +297,7 @@ static void cli_flush (struct ui_out *uiout) { cli_out_data *data = (cli_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); } @@ -313,9 +312,9 @@ cli_redirect (struct ui_out *uiout, struct ui_file *outstream) cli_out_data *data = (cli_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; } @@ -332,7 +331,7 @@ out_field_fmt (struct ui_out *uiout, int fldno, const char *format,...) { cli_out_data *data = (cli_out_data *) ui_out_data (uiout); - struct ui_file *stream = VEC_last (ui_filep, data->streams); + struct ui_file *stream = data->streams.back (); va_list args; va_start (args, format); @@ -347,7 +346,7 @@ static void field_separator (void) { cli_out_data *data = (cli_out_data *) ui_out_data (current_uiout); - struct ui_file *stream = VEC_last (ui_filep, data->streams); + struct ui_file *stream = data->streams.back (); fputc_filtered (' ', stream); } @@ -383,8 +382,7 @@ cli_out_data_ctor (cli_out_data *self, 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_output = 0; } @@ -406,13 +404,14 @@ cli_out_set_stream (struct ui_out *uiout, struct ui_file *stream) { cli_out_data *data = (cli_out_data *) ui_out_data (uiout); struct ui_file *old; - - old = VEC_pop (ui_filep, data->streams); - VEC_quick_push (ui_filep, data->streams, stream); + + old = data->streams.back (); + data->streams.pop_back (); + data->streams.push_back (stream); return old; } - + /* CLI interface to display tab-completion matches. */ /* CLI version of displayer.crlf. */ diff --git a/gdb/cli-out.h b/gdb/cli-out.h index 55d80a7..296b8c0 100644 --- a/gdb/cli-out.h +++ b/gdb/cli-out.h @@ -21,19 +21,14 @@ #define CLI_OUT_H #include "ui-out.h" -#include "vec.h" - -/* Used for cli_ui_out_data->streams. */ - -typedef struct ui_file *ui_filep; -DEF_VEC_P (ui_filep); +#include /* These are exported so that they can be extended by other `ui_out' implementations, like TUI's. */ struct cli_ui_out_data { - VEC (ui_filep) *streams; + std::vector streams; int suppress_output; }; -- 2.10.0