diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2025-03-10 11:10:46 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2025-03-19 15:15:20 -0400 |
commit | a7f139db2216d73fb40ab6ac43377e716589f6be (patch) | |
tree | b16e1cc0935952782fdf80d9bfae0f0a7f448fc2 /gdb | |
parent | e5348a7ab3f11f4c096ee4ebcdb9eb2663337357 (diff) | |
download | binutils-a7f139db2216d73fb40ab6ac43377e716589f6be.zip binutils-a7f139db2216d73fb40ab6ac43377e716589f6be.tar.gz binutils-a7f139db2216d73fb40ab6ac43377e716589f6be.tar.bz2 |
gdb: C++-ify internal_function
Change the `name` field to std::string, add constructor. Remove
function `create_internal_function`, since it becomes a trivial wrapper
around the constructor.
Change-Id: Ifc8b1282c442e1930bcd69d6e140128067e49563
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/value.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/gdb/value.c b/gdb/value.c index e498632..18c9f74 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -55,10 +55,17 @@ /* Definition of a user function. */ struct internal_function { + internal_function (std::string name, internal_function_fn_noside handler, + void *cookie) + : name (std::move (name)), + handler (handler), + cookie (cookie) + {} + /* The name of the function. It is a bit odd to have this in the function itself -- the user might use a differently-named convenience variable to hold the function. */ - char *name; + std::string name; /* The handler. */ internal_function_fn_noside handler; @@ -2316,18 +2323,6 @@ internalvar_name (const struct internalvar *var) return var->name.c_str (); } -static struct internal_function * -create_internal_function (const char *name, - internal_function_fn_noside handler, void *cookie) -{ - struct internal_function *ifn = new (struct internal_function); - - ifn->name = xstrdup (name); - ifn->handler = handler; - ifn->cookie = cookie; - return ifn; -} - const char * value_internal_function_name (struct value *val) { @@ -2338,7 +2333,7 @@ value_internal_function_name (struct value *val) result = get_internalvar_function (VALUE_INTERNALVAR (val), &ifn); gdb_assert (result); - return ifn->name; + return ifn->name.c_str (); } struct value * @@ -2376,7 +2371,7 @@ do_add_internal_function (const char *name, const char *doc, struct internal_function *ifn; struct internalvar *var = lookup_internalvar (name); - ifn = create_internal_function (name, handler, cookie); + ifn = new internal_function (name, handler, cookie); set_internalvar_function (var, ifn); return add_cmd (name, no_class, function_command, doc, &functionlist); |