diff options
author | Doug Evans <dje@google.com> | 2014-06-03 13:48:12 -0700 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2014-06-03 13:48:12 -0700 |
commit | a5b1fd27801326156c2263b867297e80bcf9fe3d (patch) | |
tree | 32642c2c3b4b920d559cd25073a8c6fa7df9f204 /gdb/exec.c | |
parent | 33ac0ca144af42a986a21fcf9c978b4d75b8174c (diff) | |
download | binutils-a5b1fd27801326156c2263b867297e80bcf9fe3d.tar.gz binutils-a5b1fd27801326156c2263b867297e80bcf9fe3d.tar.bz2 binutils-a5b1fd27801326156c2263b867297e80bcf9fe3d.zip |
resize_section_table cleanup
* exec.c (exec_close_1): Call clear_section_table instead of
resize_section_table.
(clear_section_table): New function.
(resize_section_table): Make static. Rename arg num_added to
adjustment.
* exec.h (clear_section_table): Declare.
(resize_section_table): Delete.
* progspace.c (release_program_space): Call clear_section_table
instead of resize_section_table.
Diffstat (limited to 'gdb/exec.c')
-rw-r--r-- | gdb/exec.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/gdb/exec.c b/gdb/exec.c index ca59c72bab2..087c1222043 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -125,12 +125,7 @@ exec_close_1 (struct target_ops *self) ALL_PSPACES (ss) { set_current_program_space (ss); - - /* Delete all target sections. */ - resize_section_table - (current_target_sections, - -resize_section_table (current_target_sections, 0)); - + clear_section_table (current_target_sections); exec_close (); } @@ -366,15 +361,29 @@ add_to_section_table (bfd *abfd, struct bfd_section *asect, (*table_pp)++; } -int -resize_section_table (struct target_section_table *table, int num_added) +/* See exec.h. */ + +void +clear_section_table (struct target_section_table *table) +{ + xfree (table->sections); + table->sections = table->sections_end = NULL; +} + +/* Resize section table TABLE by ADJUSTMENT. + ADJUSTMENT may be negative, in which case the caller must have already + removed the sections being deleted. + Returns the old size. */ + +static int +resize_section_table (struct target_section_table *table, int adjustment) { int old_count; int new_count; old_count = table->sections_end - table->sections; - new_count = num_added + old_count; + new_count = adjustment + old_count; if (new_count) { @@ -383,10 +392,7 @@ resize_section_table (struct target_section_table *table, int num_added) table->sections_end = table->sections + new_count; } else - { - xfree (table->sections); - table->sections = table->sections_end = NULL; - } + clear_section_table (table); return old_count; } |