From d0d292a27402ee2d3f91d541371f134f91730373 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sat, 14 Oct 2017 08:42:23 -0400 Subject: Use std::vector for traceframe_info::tvars Straightforward change to get rid of a VEC. We need to new/delete traceframe_info instead of malloc/free it. I found three places that allocate a traceframe_info (ctf_traceframe_info, tfile_traceframe_info and parse_traceframe_info) and only one that frees it (free_traceframe_info). gdb/ChangeLog: * tracepoint.h (struct traceframe_info) : Change type to std::vector. * tracepoint.c (free_traceframe_info): Deallocate with delete. (traceframe_info_start_tvar): Adjust to vector change. (parse_traceframe_info): Allocate with new. * ctf.c (ctf_traceframe_info): Allocate with new, adjust to vector change. * tracefile-tfile.c (build_traceframe_info): Adjust to vector change. tfile_traceframe_info): Allocate with new. * mi/mi-main.c (mi_cmd_trace_frame_collected): Adjust to vector change. --- gdb/tracepoint.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'gdb/tracepoint.c') diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index bbfc2ce..2605c0a 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -199,9 +199,8 @@ free_traceframe_info (struct traceframe_info *info) if (info != NULL) { VEC_free (mem_range_s, info->memory); - VEC_free (int, info->tvars); - xfree (info); + delete info; } } @@ -4025,7 +4024,7 @@ traceframe_info_start_tvar (struct gdb_xml_parser *parser, = (const char *) xml_find_attribute (attributes, "id")->value; int id = gdb_xml_parse_ulongest (parser, id_attrib); - VEC_safe_push (int, info->tvars, id); + info->tvars.push_back (id); } /* Discard the constructed trace frame info (if an error occurs). */ @@ -4072,10 +4071,9 @@ static const struct gdb_xml_element traceframe_info_elements[] = { struct traceframe_info * parse_traceframe_info (const char *tframe_info) { - struct traceframe_info *result; + traceframe_info *result = new traceframe_info; struct cleanup *back_to; - result = XCNEW (struct traceframe_info); back_to = make_cleanup (free_result, result); if (gdb_xml_parse_quick (_("trace frame info"), -- cgit v1.1