From a18ba4e4c9d64eeb2ea65e5315fbd8b4261a1756 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 30 Mar 2018 17:18:54 -0400 Subject: Use std::vector in uploaded_tp This patch changes the VEC(char_ptr) fields in uploaded_tp to use std::vector. At first, I wanted to creep in more changes, like using std::string, but it was making the patch too big and less focused, so I decided to keep it to just that. It also looks like the strings in those vectors are never free'd. If so, we can fix that in another patch. gdb/ChangeLog: * tracepoint.h (struct uploaded_tp): Initialize fields. : Change type to std::vector. * tracepoint.c (get_uploaded_tp): Allocate with new. (free_uploaded_tps): Free with delete. (parse_tracepoint_definition): Adjust to std::vector change. * breakpoint.c (read_uploaded_action): Likewise. (create_tracepoint_from_upload): Likewise. * ctf.c (ctf_write_uploaded_tp): Likewise. (SET_ARRAY_FIELD): Likewise. * tracefile-tfile.c (tfile_write_uploaded_tp): Likewise. --- gdb/tracepoint.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'gdb/tracepoint.c') diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 965c236..954d039 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3062,12 +3062,9 @@ get_uploaded_tp (int num, ULONGEST addr, struct uploaded_tp **utpp) if (utp->number == num && utp->addr == addr) return utp; - utp = XCNEW (struct uploaded_tp); + utp = new uploaded_tp; utp->number = num; utp->addr = addr; - utp->actions = NULL; - utp->step_actions = NULL; - utp->cmd_strings = NULL; utp->next = *utpp; *utpp = utp; @@ -3082,7 +3079,7 @@ free_uploaded_tps (struct uploaded_tp **utpp) while (*utpp) { next_one = (*utpp)->next; - xfree (*utpp); + delete *utpp; *utpp = next_one; } } @@ -3599,12 +3596,12 @@ parse_tracepoint_definition (const char *line, struct uploaded_tp **utpp) else if (piece == 'A') { utp = get_uploaded_tp (num, addr, utpp); - VEC_safe_push (char_ptr, utp->actions, xstrdup (p)); + utp->actions.push_back (xstrdup (p)); } else if (piece == 'S') { utp = get_uploaded_tp (num, addr, utpp); - VEC_safe_push (char_ptr, utp->step_actions, xstrdup (p)); + utp->step_actions.push_back (xstrdup (p)); } else if (piece == 'Z') { @@ -3628,7 +3625,7 @@ parse_tracepoint_definition (const char *line, struct uploaded_tp **utpp) else if (startswith (srctype, "cond:")) utp->cond_string = xstrdup (buf); else if (startswith (srctype, "cmd:")) - VEC_safe_push (char_ptr, utp->cmd_strings, xstrdup (buf)); + utp->cmd_strings.push_back (xstrdup (buf)); } else if (piece == 'V') { -- cgit v1.1