diff options
author | Tom Tromey <tom@tromey.com> | 2023-08-27 12:11:00 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-11-07 17:30:15 -0700 |
commit | 426931be4b538078c89c09d89ae3ecbab3146f46 (patch) | |
tree | 1e07032d9436e655db96d5a724fc5e3d61b21bef /bfd/bfd.c | |
parent | 9da76ef30c4001de2f84ebfc9c67f7424f3b7387 (diff) | |
download | gdb-426931be4b538078c89c09d89ae3ecbab3146f46.zip gdb-426931be4b538078c89c09d89ae3ecbab3146f46.tar.gz gdb-426931be4b538078c89c09d89ae3ecbab3146f46.tar.bz2 |
Make _bfd_error_buf static
This makes _bfd_error_buf static and adds a way to clear it. I felt
that this made the subsequent patches a little cleaner.
* bfd.c (_bfd_error_buf): Now static.
(bfd_set_input_error): Use _bfd_clear_error_data.
(_bfd_clear_error_data): New function.
(bfd_init): Use _bfd_clear_error_data.
* libbfd.h: Regenerate.
* opncls.c (bfd_close_all_done): Use _bfd_clear_error_data.
* po/bfd.pot: Regenerate.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r-- | bfd/bfd.c | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -726,16 +726,12 @@ CODE_FRAGMENT .} .bfd_error_type; . -INTERNAL -.{* A buffer that is freed on bfd_close. *} -.extern char *_bfd_error_buf; -. */ static bfd_error_type bfd_error; static bfd_error_type input_error; static bfd *input_bfd; -char *_bfd_error_buf; +static char *_bfd_error_buf; const char *const bfd_errmsgs[] = { @@ -823,8 +819,7 @@ bfd_set_input_error (bfd *input, bfd_error_type error_tag) /* This is an error that occurred during bfd_close when writing an archive, but on one of the input files. */ bfd_error = bfd_error_on_input; - free (_bfd_error_buf); - _bfd_error_buf = NULL; + _bfd_clear_error_data (); input_bfd = input; input_error = error_tag; if (input_error >= bfd_error_on_input) @@ -898,6 +893,24 @@ bfd_perror (const char *message) /* INTERNAL_FUNCTION + _bfd_clear_error_data + +SYNOPSIS + void _bfd_clear_error_data (void); + +DESCRIPTION + Free any data associated with the BFD error. +*/ + +void +_bfd_clear_error_data (void) +{ + free (_bfd_error_buf); + _bfd_error_buf = NULL; +} + +/* +INTERNAL_FUNCTION bfd_asprintf SYNOPSIS @@ -1725,8 +1738,7 @@ bfd_init (void) { bfd_error = bfd_error_no_error; input_bfd = NULL; - free (_bfd_error_buf); - _bfd_error_buf = NULL; + _bfd_clear_error_data (); input_error = bfd_error_no_error; _bfd_error_program_name = NULL; _bfd_error_internal = error_handler_fprintf; |