ui-out.c (default_ui_out_impl): Add comment.
[deliverable/binutils-gdb.git] / gdb / ui-out.c
index 03b1240ace9882b1174c6590675eb1f27e82393f..a87c1d36a06418ecfab6df49f78d3eaec746a128 100644 (file)
@@ -1,6 +1,6 @@
 /* Output generating routines for GDB.
 
-   Copyright (C) 1999-2013 Free Software Foundation, Inc.
+   Copyright (C) 1999-2015 Free Software Foundation, Inc.
 
    Contributed by Cygnus Solutions.
    Written by Fernando Nasser for Cygnus.
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_string.h"
 #include "expression.h"                /* For language.h */
 #include "language.h"
 #include "ui-out.h"
-#include "gdb_assert.h"
 
 /* table header structures */
 
@@ -33,7 +31,7 @@ struct ui_out_hdr
   {
     int colno;
     int width;
-    int alignment;
+    enum ui_align alignment;
     char *col_name;
     char *colhdr;
     struct ui_out_hdr *next;
@@ -102,7 +100,7 @@ struct ui_out
   {
     int flags;
     /* Specific implementation of ui-out.  */
-    struct ui_out_impl *impl;
+    const struct ui_out_impl *impl;
     void *data;
 
     /* Current level.  */
@@ -131,7 +129,7 @@ push_level (struct ui_out *uiout,
   struct ui_out_level *current;
 
   uiout->level++;
-  current = XMALLOC (struct ui_out_level);
+  current = XNEW (struct ui_out_level);
   current->field_count = 0;
   current->type = type;
   VEC_safe_push (ui_out_level_p, uiout->levels, current);
@@ -198,7 +196,7 @@ static void default_data_destroy (struct ui_out *uiout);
 
 /* This is the default ui-out implementation functions vector.  */
 
-struct ui_out_impl default_ui_out_impl =
+const struct ui_out_impl default_ui_out_impl =
 {
   default_table_begin,
   default_table_body,
@@ -215,7 +213,7 @@ struct ui_out_impl default_ui_out_impl =
   default_message,
   default_wrap_hint,
   default_flush,
-  NULL,
+  NULL, /* redirect */
   default_data_destroy,
   0, /* Does not need MI hacks.  */
 };
@@ -271,14 +269,14 @@ static void uo_data_destroy (struct ui_out *uiout);
 
 extern void _initialize_ui_out (void);
 static void append_header_to_list (struct ui_out *uiout, int width,
-                                  int alignment, const char *col_name,
+                                  enum ui_align alignment, const char *col_name,
                                   const char *colhdr);
 static int get_next_header (struct ui_out *uiout, int *colno, int *width,
-                           int *alignment, char **colhdr);
+                           enum ui_align *alignment, char **colhdr);
 static void clear_header_list (struct ui_out *uiout);
 static void clear_table (struct ui_out *uiout);
 static void verify_field (struct ui_out *uiout, int *fldno, int *width,
-                         int *align);
+                         enum ui_align *align);
 
 /* exported functions (ui_out API) */
 
@@ -397,7 +395,7 @@ specified after table_body."));
   {
     int fldno;
     int width;
-    int align;
+    enum ui_align align;
 
     verify_field (uiout, &fldno, &width, &align);
   }
@@ -443,7 +441,7 @@ make_cleanup_ui_out_end (struct ui_out *uiout,
 {
   struct ui_out_end_cleanup_data *end_cleanup_data;
 
-  end_cleanup_data = XMALLOC (struct ui_out_end_cleanup_data);
+  end_cleanup_data = XNEW (struct ui_out_end_cleanup_data);
   end_cleanup_data->uiout = uiout;
   end_cleanup_data->type = type;
   return make_cleanup (do_cleanup_end, end_cleanup_data);
@@ -472,7 +470,7 @@ ui_out_field_int (struct ui_out *uiout,
 {
   int fldno;
   int width;
-  int align;
+  enum ui_align align;
 
   verify_field (uiout, &fldno, &width, &align);
 
@@ -488,7 +486,7 @@ ui_out_field_fmt_int (struct ui_out *uiout,
 {
   int fldno;
   int width;
-  int align;
+  enum ui_align align;
 
   verify_field (uiout, &fldno, &width, &align);
 
@@ -532,7 +530,7 @@ ui_out_field_skip (struct ui_out *uiout,
 {
   int fldno;
   int width;
-  int align;
+  enum ui_align align;
 
   verify_field (uiout, &fldno, &width, &align);
 
@@ -546,7 +544,7 @@ ui_out_field_string (struct ui_out *uiout,
 {
   int fldno;
   int width;
-  int align;
+  enum ui_align align;
 
   verify_field (uiout, &fldno, &width, &align);
 
@@ -562,7 +560,7 @@ ui_out_field_fmt (struct ui_out *uiout,
   va_list args;
   int fldno;
   int width;
-  int align;
+  enum ui_align align;
 
   /* Will not align, but has to call anyway.  */
   verify_field (uiout, &fldno, &width, &align);
@@ -807,8 +805,8 @@ uo_table_header (struct ui_out *uiout, int width, enum ui_align align,
 static void
 clear_table (struct ui_out *uiout)
 {
-  if (uiout->table.id)
-    xfree (uiout->table.id);
+  xfree (uiout->table.id);
+  uiout->table.id = NULL;
   clear_header_list (uiout);
 }
 
@@ -958,13 +956,13 @@ clear_header_list (struct ui_out *uiout)
 static void
 append_header_to_list (struct ui_out *uiout,
                       int width,
-                      int alignment,
+                      enum ui_align alignment,
                       const char *col_name,
                       const char *colhdr)
 {
   struct ui_out_hdr *temphdr;
 
-  temphdr = XMALLOC (struct ui_out_hdr);
+  temphdr = XNEW (struct ui_out_hdr);
   temphdr->width = width;
   temphdr->alignment = alignment;
   /* We have to copy the column title as the original may be an
@@ -1004,7 +1002,7 @@ static int
 get_next_header (struct ui_out *uiout,
                 int *colno,
                 int *width,
-                int *alignment,
+                enum ui_align *alignment,
                 char **colhdr)
 {
   /* There may be no headers at all or we may have used all columns.  */
@@ -1025,7 +1023,8 @@ get_next_header (struct ui_out *uiout,
    available/applicable).  */
 
 static void
-verify_field (struct ui_out *uiout, int *fldno, int *width, int *align)
+verify_field (struct ui_out *uiout, int *fldno, int *width,
+             enum ui_align *align)
 {
   struct ui_out_level *current = current_level (uiout);
   char *text;
@@ -1095,11 +1094,11 @@ ui_out_query_field (struct ui_out *uiout, int colno,
 /* Initalize private members at startup.  */
 
 struct ui_out *
-ui_out_new (struct ui_out_impl *impl, void *data,
+ui_out_new (const struct ui_out_impl *impl, void *data,
            int flags)
 {
-  struct ui_out *uiout = XMALLOC (struct ui_out);
-  struct ui_out_level *current = XMALLOC (struct ui_out_level);
+  struct ui_out *uiout = XNEW (struct ui_out);
+  struct ui_out_level *current = XNEW (struct ui_out_level);
 
   uiout->data = data;
   uiout->impl = impl;
@@ -1114,6 +1113,7 @@ ui_out_new (struct ui_out_impl *impl, void *data,
   current->field_count = 0;
   VEC_safe_push (ui_out_level_p, uiout->levels, current);
 
+  uiout->table.id = NULL;
   uiout->table.header_first = NULL;
   uiout->table.header_last = NULL;
   uiout->table.header_next = NULL;
This page took 0.027395 seconds and 4 git commands to generate.