diff options
author | Tom Tromey <tom@tromey.com> | 2017-10-15 11:13:29 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-10-20 09:01:03 -0600 |
commit | 2712ce2e659f82168154d4533f53d2963ae82571 (patch) | |
tree | 99edd1b85f5c282622f27a25a5411abeb657c7ef /gdb/gdb_bfd.c | |
parent | 15763a09d4aea85fc3153d6746c040dd48565637 (diff) | |
download | gdb-2712ce2e659f82168154d4533f53d2963ae82571.zip gdb-2712ce2e659f82168154d4533f53d2963ae82571.tar.gz gdb-2712ce2e659f82168154d4533f53d2963ae82571.tar.bz2 |
Introduce new_bfd_ref
This introduces a helper function, new_bfd_ref, that calls gdb_bfd_ref
and returns a gdb_bfd_ref_ptr. Then it updates several places to use
this.
ChangeLog
2017-10-20 Tom Tromey <tom@tromey.com>
* exec.c (exec_file_attach): Use new_bfd_ref.
* symfile-mem.c (symbol_file_add_from_memory): Use new_bfd_ref.
* gdb_bfd.c (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec, gdb_bfd_fdopenr): Use
new_bfd_ref.
* gdb_bfd.h (new_bfd_ref): New function.
Diffstat (limited to 'gdb/gdb_bfd.c')
-rw-r--r-- | gdb/gdb_bfd.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 29080b8..5ba03c1 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -427,8 +427,7 @@ gdb_bfd_open (const char *name, const char *target, int fd) host_address_to_string (abfd), bfd_get_filename (abfd)); close (fd); - gdb_bfd_ref (abfd); - return gdb_bfd_ref_ptr (abfd); + return new_bfd_ref (abfd); } abfd = bfd_fopen (name, target, FOPEN_RB, fd); @@ -448,8 +447,7 @@ gdb_bfd_open (const char *name, const char *target, int fd) *slot = abfd; } - gdb_bfd_ref (abfd); - return gdb_bfd_ref_ptr (abfd); + return new_bfd_ref (abfd); } /* A helper function that releases any section data attached to the @@ -778,10 +776,7 @@ gdb_bfd_fopen (const char *filename, const char *target, const char *mode, { bfd *result = bfd_fopen (filename, target, mode, fd); - if (result) - gdb_bfd_ref (result); - - return gdb_bfd_ref_ptr (result); + return new_bfd_ref (result); } /* See gdb_bfd.h. */ @@ -791,10 +786,7 @@ gdb_bfd_openr (const char *filename, const char *target) { bfd *result = bfd_openr (filename, target); - if (result) - gdb_bfd_ref (result); - - return gdb_bfd_ref_ptr (result); + return new_bfd_ref (result); } /* See gdb_bfd.h. */ @@ -804,10 +796,7 @@ gdb_bfd_openw (const char *filename, const char *target) { bfd *result = bfd_openw (filename, target); - if (result) - gdb_bfd_ref (result); - - return gdb_bfd_ref_ptr (result); + return new_bfd_ref (result); } /* See gdb_bfd.h. */ @@ -832,10 +821,7 @@ gdb_bfd_openr_iovec (const char *filename, const char *target, open_func, open_closure, pread_func, close_func, stat_func); - if (result) - gdb_bfd_ref (result); - - return gdb_bfd_ref_ptr (result); + return new_bfd_ref (result); } /* See gdb_bfd.h. */ @@ -891,10 +877,7 @@ gdb_bfd_fdopenr (const char *filename, const char *target, int fd) { bfd *result = bfd_fdopenr (filename, target, fd); - if (result) - gdb_bfd_ref (result); - - return gdb_bfd_ref_ptr (result); + return new_bfd_ref (result); } |