diff options
author | Tom Tromey <tom@tromey.com> | 2020-10-18 10:47:48 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-07-28 14:16:50 -0600 |
commit | b382c16682acc33d2e81e5604c9dbd408be376d2 (patch) | |
tree | 46ca3ab29dfb4437dd35db2ab605fbc1ebdf1195 /gdb/progspace.c | |
parent | e5213e2c851c295c5e4c3e9b52606c1012029b67 (diff) | |
download | binutils-gdb-b382c16682acc33d2e81e5604c9dbd408be376d2.tar.gz |
Change address_space to use new and delete
This changes address_space to use new and delete, and makes some other
small C++-ification changes as well, like changing address_space_num
to be a method.
This patch was needed for the subsequent patch to rewrite the registry
system.
Diffstat (limited to 'gdb/progspace.c')
-rw-r--r-- | gdb/progspace.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/gdb/progspace.c b/gdb/progspace.c index 8735343fabc..c2e2da5a7dc 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -57,16 +57,10 @@ DEFINE_REGISTRY (address_space, REGISTRY_ACCESS_FIELD) /* Create a new address space object, and add it to the list. */ -struct address_space * -new_address_space (void) +address_space::address_space () + : m_num (++highest_address_space_num) { - struct address_space *aspace; - - aspace = XCNEW (struct address_space); - aspace->num = ++highest_address_space_num; - address_space_alloc_data (aspace); - - return aspace; + address_space_alloc_data (this); } /* Maybe create a new address space object, and add it to the list, or @@ -84,20 +78,12 @@ maybe_new_address_space (void) return program_spaces[0]->aspace; } - return new_address_space (); -} - -static void -free_address_space (struct address_space *aspace) -{ - address_space_free_data (aspace); - xfree (aspace); + return new address_space (); } -int -address_space_num (struct address_space *aspace) +address_space::~address_space () { - return aspace->num; + address_space_free_data (this); } /* Start counting over from scratch. */ @@ -153,7 +139,7 @@ program_space::~program_space () locations for this pspace which we're tearing down. */ clear_symtab_users (SYMFILE_DEFER_BP_RESET); if (!gdbarch_has_shared_address_space (target_gdbarch ())) - free_address_space (this->aspace); + delete this->aspace; /* Discard any data modules have associated with the PSPACE. */ program_space_free_data (this); } @@ -411,17 +397,17 @@ update_address_spaces (void) if (shared_aspace) { - struct address_space *aspace = new_address_space (); + struct address_space *aspace = new address_space (); - free_address_space (current_program_space->aspace); + delete current_program_space->aspace; for (struct program_space *pspace : program_spaces) pspace->aspace = aspace; } else for (struct program_space *pspace : program_spaces) { - free_address_space (pspace->aspace); - pspace->aspace = new_address_space (); + delete pspace->aspace; + pspace->aspace = new address_space (); } for (inferior *inf : all_inferiors ()) @@ -459,5 +445,5 @@ initialize_progspace (void) modules have done that. Do this before initialize_current_architecture, because that accesses the ebfd of current_program_space. */ - current_program_space = new program_space (new_address_space ()); + current_program_space = new program_space (new address_space ()); } |