diff options
author | Tom Tromey <tom@tromey.com> | 2023-12-10 07:45:24 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-12-13 14:12:52 -0700 |
commit | fde841947e445a98f22a04465daa75a9fb6af051 (patch) | |
tree | f95774d5b6c4e560ee50c593ffd3241f8e0519bc /gdb/location.h | |
parent | e7cdec6605837a5b79442fc06bd66d6372025040 (diff) | |
download | gdb-fde841947e445a98f22a04465daa75a9fb6af051.zip gdb-fde841947e445a98f22a04465daa75a9fb6af051.tar.gz gdb-fde841947e445a98f22a04465daa75a9fb6af051.tar.bz2 |
Use unique_xmalloc_ptr in explicit_location_spec
This changes explicit_location_spec to use unique_xmalloc_ptr,
removing some manual memory management.
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Diffstat (limited to 'gdb/location.h')
-rw-r--r-- | gdb/location.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/gdb/location.h b/gdb/location.h index e39a948..acbc286 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -190,9 +190,12 @@ protected: struct explicit_location_spec : public location_spec { - explicit_location_spec (); + explicit explicit_location_spec (const char *function_name); - ~explicit_location_spec (); + explicit_location_spec () + : explicit_location_spec (nullptr) + { + } location_spec_up clone () const override; @@ -203,18 +206,18 @@ struct explicit_location_spec : public location_spec canonicalized/valid. */ std::string to_linespec () const; - /* The source filename. Malloc'd. */ - char *source_filename = nullptr; + /* The source filename. */ + gdb::unique_xmalloc_ptr<char> source_filename; - /* The function name. Malloc'd. */ - char *function_name = nullptr; + /* The function name. */ + gdb::unique_xmalloc_ptr<char> function_name; /* Whether the function name is fully-qualified or not. */ symbol_name_match_type func_name_match_type = symbol_name_match_type::WILD; - /* The name of a label. Malloc'd. */ - char *label_name = nullptr; + /* The name of a label. */ + gdb::unique_xmalloc_ptr<char> label_name; /* A line offset relative to the start of the symbol identified by the above fields or the current symtab @@ -284,10 +287,7 @@ const probe_location_spec * static inline location_spec_up new_explicit_location_spec_function (const char *function_name) { - explicit_location_spec *spec - = new explicit_location_spec (); - spec->function_name - = (function_name != nullptr ? xstrdup (function_name) : nullptr); + explicit_location_spec *spec = new explicit_location_spec (function_name); return location_spec_up (spec); } |