aboutsummaryrefslogtreecommitdiff
path: root/gdb/guile/scm-exception.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2021-11-08 14:58:46 +0000
committerAndrew Burgess <aburgess@redhat.com>2021-11-16 17:45:45 +0000
commit8579fd136a614985bd27f20539c7bb7c5a51287d (patch)
treefb84850409a44e13e832cbadc9025d40c1d33d9f /gdb/guile/scm-exception.c
parent2bb7589ddf61e163f2e414e7033fad56ea17e784 (diff)
downloadbinutils-8579fd136a614985bd27f20539c7bb7c5a51287d.zip
binutils-8579fd136a614985bd27f20539c7bb7c5a51287d.tar.gz
binutils-8579fd136a614985bd27f20539c7bb7c5a51287d.tar.bz2
gdb/gdbsupport: make xstrprintf and xstrvprintf return a unique_ptr
The motivation is to reduce the number of places where unmanaged pointers are returned from allocation type routines. All of the callers are updated. There should be no user visible changes after this commit.
Diffstat (limited to 'gdb/guile/scm-exception.c')
-rw-r--r--gdb/guile/scm-exception.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/gdb/guile/scm-exception.c b/gdb/guile/scm-exception.c
index b62eaeb..0c9cb5d 100644
--- a/gdb/guile/scm-exception.c
+++ b/gdb/guile/scm-exception.c
@@ -234,7 +234,7 @@ SCM
gdbscm_make_type_error (const char *subr, int arg_pos, SCM bad_value,
const char *expected_type)
{
- char *msg;
+ gdb::unique_xmalloc_ptr<char> msg;
SCM result;
if (arg_pos > 0)
@@ -262,9 +262,8 @@ gdbscm_make_type_error (const char *subr, int arg_pos, SCM bad_value,
msg = xstrprintf (_("Wrong type argument: ~S"));
}
- result = gdbscm_make_error (scm_arg_type_key, subr, msg,
+ result = gdbscm_make_error (scm_arg_type_key, subr, msg.get (),
scm_list_1 (bad_value), scm_list_1 (bad_value));
- xfree (msg);
return result;
}
@@ -279,7 +278,7 @@ static SCM
gdbscm_make_arg_error (SCM key, const char *subr, int arg_pos, SCM bad_value,
const char *error_prefix, const char *error)
{
- char *msg;
+ gdb::unique_xmalloc_ptr<char> msg;
SCM result;
if (error_prefix != NULL)
@@ -300,9 +299,8 @@ gdbscm_make_arg_error (SCM key, const char *subr, int arg_pos, SCM bad_value,
msg = xstrprintf (_("%s: ~S"), error);
}
- result = gdbscm_make_error (key, subr, msg,
- scm_list_1 (bad_value), scm_list_1 (bad_value));
- xfree (msg);
+ result = gdbscm_make_error (key, subr, msg.get (), scm_list_1 (bad_value),
+ scm_list_1 (bad_value));
return result;
}