From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 3/3] Remove usage of VEC(char_ptr) in gdbscm_parse_function_args
Date: Wed, 21 Mar 2018 21:25:00 -0000 [thread overview]
Message-ID: <1521667509-303-3-git-send-email-simon.marchi@ericsson.com> (raw)
In-Reply-To: <1521667509-303-1-git-send-email-simon.marchi@ericsson.com>
From: Simon Marchi <simon.marchi@polymtl.ca>
This is a straightforward replacement, no change in behavior are
intended/expected.
This is the last usage of VEC(char_ptr), so it can now be removed.
gdb/ChangeLog:
* guile/scm-utils.c (gdbscm_parse_function_args): Replace VEC
with std::vector.
* common/gdb_vecs.h (DEF_VEC_P (char_ptr)): Remove.
---
gdb/common/gdb_vecs.h | 2 --
gdb/guile/scm-utils.c | 13 ++++---------
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/gdb/common/gdb_vecs.h b/gdb/common/gdb_vecs.h
index 7318e53..8bb7015 100644
--- a/gdb/common/gdb_vecs.h
+++ b/gdb/common/gdb_vecs.h
@@ -25,8 +25,6 @@
typedef char *char_ptr;
typedef const char *const_char_ptr;
-DEF_VEC_P (char_ptr);
-
DEF_VEC_P (const_char_ptr);
/* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
diff --git a/gdb/guile/scm-utils.c b/gdb/guile/scm-utils.c
index c31afc6..73b0dec 100644
--- a/gdb/guile/scm-utils.c
+++ b/gdb/guile/scm-utils.c
@@ -386,7 +386,7 @@ gdbscm_parse_function_args (const char *func_name,
SCM status;
SCM rest = SCM_EOL;
/* Keep track of malloc'd strings. We need to free them upon error. */
- VEC (char_ptr) *allocated_strings = NULL;
+ std::vector<char *> allocated_strings;
char *ptr;
have_rest = validate_arg_format (format);
@@ -419,7 +419,7 @@ gdbscm_parse_function_args (const char *func_name,
if (!gdbscm_is_false (status))
goto fail;
if (*p == 's')
- VEC_safe_push (char_ptr, allocated_strings, *(char **) arg_ptr);
+ allocated_strings.push_back (*(char **) arg_ptr);
}
++p;
++position;
@@ -485,10 +485,7 @@ gdbscm_parse_function_args (const char *func_name,
if (!gdbscm_is_false (status))
goto fail;
if (p[i] == 's')
- {
- VEC_safe_push (char_ptr, allocated_strings,
- *(char **) arg_ptr);
- }
+ allocated_strings.push_back (*(char **) arg_ptr);
}
}
}
@@ -516,14 +513,12 @@ gdbscm_parse_function_args (const char *func_name,
}
va_end (args);
- VEC_free (char_ptr, allocated_strings);
return;
fail:
va_end (args);
- for (i = 0; VEC_iterate (char_ptr, allocated_strings, i, ptr); ++i)
+ for (char *ptr : allocated_strings)
xfree (ptr);
- VEC_free (char_ptr, allocated_strings);
gdbscm_throw (status);
}
\f
--
2.7.4
next prev parent reply other threads:[~2018-03-21 21:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 21:25 [PATCH 1/3] Use std::vector in uploaded_tp Simon Marchi
2018-03-21 21:25 ` [PATCH 2/3] Use std::vector and std::string instead of VEC(char_ptr) in gdbserver tdesc Simon Marchi
2018-03-21 21:25 ` Simon Marchi [this message]
2018-04-01 16:29 ` [PATCH 3/3] Remove usage of VEC(char_ptr) in gdbscm_parse_function_args Tom Tromey
2018-04-01 18:25 ` Simon Marchi
2018-04-02 2:23 ` Tom Tromey
2018-03-30 21:20 ` [PATCH 1/3] Use std::vector in uploaded_tp Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1521667509-303-3-git-send-email-simon.marchi@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox