Use new/delete instead of malloc/free-based functions
The following patches introduce C++ vectors and strings as fields of the various ui_out structures. We therefore need to use new/delete so that their contructor/destructor is called. I find it simpler to change all the allocations in a separate preliminary patch, rather than in each individual patch. gdb/ChangeLog: * cli-out.c (cli_uiout_dtor): Use delete instead of xfree. (cli_out_new): Use new instead of XNEW. * mi/mi-out.c (mi_out_data_dtor): Use delete instead of xfree. (mi_out_new): Use new instead of XNEW. * tui/tui-out.c (tui_out_new): Likewise. * ui-out.c (push_level): Likewise. (pop_level): Use delete instead of xfree. (clear_header_list): Use delete instead of xfree. (append_header_to_list): Use new instead of XNEW. (ui_out_new): Likewise.
This commit is contained in:
parent
5084b13657
commit
5486f16481
|
@ -1,3 +1,16 @@
|
|||
2016-11-30 Simon Marchi <simon.marchi@polymtl.ca>
|
||||
|
||||
* cli-out.c (cli_uiout_dtor): Use delete instead of xfree.
|
||||
(cli_out_new): Use new instead of XNEW.
|
||||
* mi/mi-out.c (mi_out_data_dtor): Use delete instead of xfree.
|
||||
(mi_out_new): Use new instead of XNEW.
|
||||
* tui/tui-out.c (tui_out_new): Likewise.
|
||||
* ui-out.c (push_level): Likewise.
|
||||
(pop_level): Use delete instead of xfree.
|
||||
(clear_header_list): Use delete instead of xfree.
|
||||
(append_header_to_list): Use new instead of XNEW.
|
||||
(ui_out_new): Likewise.
|
||||
|
||||
2016-11-30 Simon Marchi <simon.marchi@polymtl.ca>
|
||||
|
||||
* disable-implicit-rules.mk: New file.
|
||||
|
|
|
@ -47,7 +47,7 @@ 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);
|
||||
xfree (data);
|
||||
delete data;
|
||||
}
|
||||
|
||||
/* These are the CLI output functions */
|
||||
|
@ -395,7 +395,7 @@ struct ui_out *
|
|||
cli_out_new (struct ui_file *stream)
|
||||
{
|
||||
int flags = ui_source_list;
|
||||
cli_out_data *data = XNEW (cli_out_data);
|
||||
cli_out_data *data = new cli_out_data ();
|
||||
|
||||
cli_out_data_ctor (data, stream);
|
||||
return ui_out_new (&cli_ui_out_impl, data, flags);
|
||||
|
|
|
@ -413,7 +413,7 @@ 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);
|
||||
xfree (data);
|
||||
delete data;
|
||||
}
|
||||
|
||||
/* Initialize private members at startup. */
|
||||
|
@ -422,7 +422,7 @@ struct ui_out *
|
|||
mi_out_new (int mi_version)
|
||||
{
|
||||
int flags = 0;
|
||||
mi_out_data *data = XNEW (mi_out_data);
|
||||
mi_out_data *data = new mi_out_data ();
|
||||
struct ui_file *stream = mem_fileopen ();
|
||||
|
||||
mi_out_data_ctor (data, mi_version, stream);
|
||||
|
|
|
@ -147,7 +147,7 @@ tui_out_new (struct ui_file *stream)
|
|||
{
|
||||
int flags = 0;
|
||||
|
||||
tui_out_data *data = XNEW (tui_out_data);
|
||||
tui_out_data *data = new tui_out_data ();
|
||||
|
||||
/* Initialize base "class". */
|
||||
cli_out_data_ctor (&data->base, stream);
|
||||
|
|
13
gdb/ui-out.c
13
gdb/ui-out.c
|
@ -120,7 +120,7 @@ push_level (struct ui_out *uiout,
|
|||
struct ui_out_level *current;
|
||||
|
||||
uiout->level++;
|
||||
current = XNEW (struct ui_out_level);
|
||||
current = new ui_out_level ();
|
||||
current->field_count = 0;
|
||||
current->type = type;
|
||||
VEC_safe_push (ui_out_level_p, uiout->levels, current);
|
||||
|
@ -139,7 +139,7 @@ pop_level (struct ui_out *uiout,
|
|||
gdb_assert (uiout->level > 0);
|
||||
gdb_assert (current_level (uiout)->type == type);
|
||||
current = VEC_pop (ui_out_level_p, uiout->levels);
|
||||
xfree (current);
|
||||
delete current;
|
||||
uiout->level--;
|
||||
return uiout->level + 1;
|
||||
}
|
||||
|
@ -708,8 +708,9 @@ clear_header_list (struct ui_out *uiout)
|
|||
uiout->table.header_first = uiout->table.header_first->next;
|
||||
xfree (uiout->table.header_next->colhdr);
|
||||
xfree (uiout->table.header_next->col_name);
|
||||
xfree (uiout->table.header_next);
|
||||
delete uiout->table.header_next;
|
||||
}
|
||||
|
||||
gdb_assert (uiout->table.header_first == NULL);
|
||||
uiout->table.header_last = NULL;
|
||||
uiout->table.header_next = NULL;
|
||||
|
@ -724,7 +725,7 @@ append_header_to_list (struct ui_out *uiout,
|
|||
{
|
||||
struct ui_out_hdr *temphdr;
|
||||
|
||||
temphdr = XNEW (struct ui_out_hdr);
|
||||
temphdr = new ui_out_hdr ();
|
||||
temphdr->width = width;
|
||||
temphdr->alignment = alignment;
|
||||
/* We have to copy the column title as the original may be an
|
||||
|
@ -859,8 +860,8 @@ struct ui_out *
|
|||
ui_out_new (const struct ui_out_impl *impl, void *data,
|
||||
int flags)
|
||||
{
|
||||
struct ui_out *uiout = XNEW (struct ui_out);
|
||||
struct ui_out_level *current = XNEW (struct ui_out_level);
|
||||
struct ui_out *uiout = new ui_out ();
|
||||
struct ui_out_level *current = new ui_out_level ();
|
||||
|
||||
uiout->data = data;
|
||||
uiout->impl = impl;
|
||||
|
|
Loading…
Reference in New Issue