Replace hand-made linked list of ui_out_hdr by vector and iterator
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 1 Dec 2016 20:58:40 +0000 (15:58 -0500)
committerSimon Marchi <simon.marchi@ericsson.com>
Thu, 1 Dec 2016 20:58:40 +0000 (15:58 -0500)
commit78afa7f8599e46eb94a93510b383dfb35e549f7e
tree61e6920e2e5b4b1263b8800f7161f3085dbd7344
parent0f1254327820d7b3f67f873aa40e76679f067288
Replace hand-made linked list of ui_out_hdr by vector and iterator

Instead of keeping pointers to first, last and current ui_out_hdr in
ui_out_table, we can use an std::vector and an iterator.  Direct random
access of to vector helps make get_next_header a bit nicer by avoiding
iterating on all the headers.  append_header_to_list is also a bit
simpler.

Also, using unique_ptr inside the vector allows expressing the ownership
of the ui_out_hdr objects by the ui_out_table object, and it simplifies
the destruction.

gdb/ChangeLog:

* ui-out.c (struct ui_out_hdr) <next>: Remove.
(struct ui_out_table) <header_first, header_last, header_next>: Remove.
<headers, headers_iterator>: New fields.
(ui_out_table_body): Update for the new data structure.
(ui_out_begin): Likewise.
(clear_header_list): Likewise.
(append_header_to_list): Likewise.
(get_next_header): Likewise.
(ui_out_query_field): Likewise.
(ui_out_new): Likewise.
gdb/ChangeLog
gdb/ui-out.c