aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-darwin.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-10-10 14:47:13 -0400
committerSimon Marchi <simon.marchi@efficios.com>2023-10-19 10:57:51 -0400
commit7ad0a42e88c09b4046205316bd6352dfb31afd79 (patch)
treeb64102b23c6e0bcd53196a21e2c11ba919c6b61f /gdb/solib-darwin.c
parent1c0dfccba7bac021456198597fdce080d4a8315b (diff)
downloadbinutils-7ad0a42e88c09b4046205316bd6352dfb31afd79.zip
binutils-7ad0a42e88c09b4046205316bd6352dfb31afd79.tar.gz
binutils-7ad0a42e88c09b4046205316bd6352dfb31afd79.tar.bz2
gdb: make so_list::lm_info a unique_ptr
Make it a unique_ptr, so it gets automatically deleted when the so_list is deleted. Change-Id: Ib62d60ae2a80656239860b80e4359121c93da13d Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Diffstat (limited to 'gdb/solib-darwin.c')
-rw-r--r--gdb/solib-darwin.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 78a27ec..31a0b2f 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -275,14 +275,15 @@ darwin_current_sos (void)
/* Create and fill the new so_list element. */
so_list *newobj = new so_list;
- lm_info_darwin *li = new lm_info_darwin;
- newobj->lm_info = li;
+ auto li = gdb::make_unique<lm_info_darwin> ();
strncpy (newobj->so_name, file_path.get (), SO_NAME_MAX_PATH_SIZE - 1);
newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
strcpy (newobj->so_original_name, newobj->so_name);
li->lm_addr = load_addr;
+ newobj->lm_info = std::move (li);
+
if (head == NULL)
head = newobj;
else
@@ -614,7 +615,7 @@ darwin_clear_solib (program_space *pspace)
static void
darwin_relocate_section_addresses (so_list &so, target_section *sec)
{
- auto *li = gdb::checked_static_cast<lm_info_darwin *> (so.lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_darwin *> (so.lm_info.get ());
sec->addr += li->lm_addr;
sec->endaddr += li->lm_addr;