summaryrefslogtreecommitdiff
path: root/gdb/ui-out.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/ui-out.c')
-rw-r--r--gdb/ui-out.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index cd7e33efa59..36c4b156f58 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -185,6 +185,7 @@ static void default_message (struct ui_out *uiout, int verbosity,
va_list args) ATTRIBUTE_PRINTF (3, 0);
static void default_wrap_hint (struct ui_out *uiout, char *identstring);
static void default_flush (struct ui_out *uiout);
+static void default_data_destroy (struct ui_out *uiout);
/* This is the default ui-out implementation functions vector. */
@@ -206,6 +207,7 @@ struct ui_out_impl default_ui_out_impl =
default_wrap_hint,
default_flush,
NULL,
+ default_data_destroy,
0, /* Does not need MI hacks. */
};
@@ -254,6 +256,7 @@ static void uo_message (struct ui_out *uiout, int verbosity,
static void uo_wrap_hint (struct ui_out *uiout, char *identstring);
static void uo_flush (struct ui_out *uiout);
static int uo_redirect (struct ui_out *uiout, struct ui_file *outstream);
+static void uo_data_destroy (struct ui_out *uiout);
/* Prototypes for local functions */
@@ -264,6 +267,7 @@ static void append_header_to_list (struct ui_out *uiout, int width,
static int get_next_header (struct ui_out *uiout, int *colno, int *width,
int *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);
@@ -328,10 +332,7 @@ ui_out_table_end (struct ui_out *uiout)
uiout->table.flag = 0;
uo_table_end (uiout);
-
- if (uiout->table.id)
- xfree (uiout->table.id);
- clear_header_list (uiout);
+ clear_table (uiout);
}
void
@@ -749,6 +750,11 @@ default_flush (struct ui_out *uiout)
{
}
+static void
+default_data_destroy (struct ui_out *uiout)
+{
+}
+
/* Interface to the implementation functions. */
void
@@ -787,6 +793,16 @@ uo_table_header (struct ui_out *uiout, int width, enum ui_align align,
uiout->impl->table_header (uiout, width, align, col_name, colhdr);
}
+/* Clear the table associated with UIOUT. */
+
+static void
+clear_table (struct ui_out *uiout)
+{
+ if (uiout->table.id)
+ xfree (uiout->table.id);
+ clear_header_list (uiout);
+}
+
void
uo_begin (struct ui_out *uiout,
enum ui_out_type type,
@@ -901,6 +917,15 @@ uo_redirect (struct ui_out *uiout, struct ui_file *outstream)
return 0;
}
+void
+uo_data_destroy (struct ui_out *uiout)
+{
+ if (!uiout->impl->data_destroy)
+ return;
+
+ uiout->impl->data_destroy (uiout);
+}
+
/* local functions */
/* List of column headers manipulation routines. */
@@ -1079,6 +1104,16 @@ ui_out_new (struct ui_out_impl *impl, void *data,
return uiout;
}
+/* Free UIOUT and the memory areas it references. */
+
+void
+ui_out_destroy (struct ui_out *uiout)
+{
+ uo_data_destroy (uiout);
+ clear_table (uiout);
+ xfree (uiout);
+}
+
/* Standard gdb initialization hook. */
void