summaryrefslogtreecommitdiff
path: root/gdb/cp-support.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-10-09 15:57:36 +0100
committerPedro Alves <palves@redhat.com>2017-10-09 15:57:36 +0100
commit109483d9eec3f0d0c3eaafd5d829435059167c52 (patch)
tree4c41fa833332e7c4ae832313e3027eb70d5bcf2b /gdb/cp-support.c
parentc474ea1a5f1524668cb8ce91c3682cb0cb837e08 (diff)
downloadbinutils-gdb-109483d9eec3f0d0c3eaafd5d829435059167c52.tar.gz
Make cp_remove_params return a gdb::unique_xmalloc_ptr
Use the type system instead of callers needing to know how the returned string's memory is supposed to be managed. gdb/ChangeLog: 2017-10-09 Pedro Alves <palves@redhat.com> * cp-support.c (cp_remove_params): Return a gdb::unique_xmalloc_ptr. Use bool. (overload_list_add_symbol): Adjust to use gdb::unique_xmalloc_ptr. * cp-support.h (cp_remove_params): Now returns a gdb::unique_xmalloc_ptr. * dwarf2read.c (find_slot_in_mapped_hash): Now returns bool. Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr. * psymtab.c (psymtab_search_name): Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr. (lookup_partial_symbol): Adjust to use gdb::unique_xmalloc_ptr. * stack.c (find_frame_funname): Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr.
Diffstat (limited to 'gdb/cp-support.c')
-rw-r--r--gdb/cp-support.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index d88bdaa9251..7bcb155a7f4 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -838,10 +838,10 @@ cp_func_name (const char *full_name)
(optionally) a return type. Return the name of the function without
parameters or return type, or NULL if we can not parse the name. */
-char *
+gdb::unique_xmalloc_ptr<char>
cp_remove_params (const char *demangled_name)
{
- int done = 0;
+ bool done = false;
struct demangle_component *ret_comp;
std::unique_ptr<demangle_parse_info> info;
gdb::unique_xmalloc_ptr<char> ret;
@@ -868,7 +868,7 @@ cp_remove_params (const char *demangled_name)
ret_comp = d_left (ret_comp);
break;
default:
- done = 1;
+ done = true;
break;
}
@@ -876,7 +876,7 @@ cp_remove_params (const char *demangled_name)
if (ret_comp->type == DEMANGLE_COMPONENT_TYPED_NAME)
ret = cp_comp_to_string (d_left (ret_comp), 10);
- return ret.release ();
+ return ret;
}
/* Here are some random pieces of trivia to keep in mind while trying
@@ -1103,7 +1103,7 @@ overload_list_add_symbol (struct symbol *sym,
{
int newsize;
int i;
- char *sym_name;
+ gdb::unique_xmalloc_ptr<char> sym_name;
/* If there is no type information, we can't do anything, so
skip. */
@@ -1122,13 +1122,8 @@ overload_list_add_symbol (struct symbol *sym,
return;
/* skip symbols that cannot match */
- if (strcmp (sym_name, oload_name) != 0)
- {
- xfree (sym_name);
- return;
- }
-
- xfree (sym_name);
+ if (strcmp (sym_name.get (), oload_name) != 0)
+ return;
/* We have a match for an overload instance, so add SYM to the
current list of overload instances */