aboutsummaryrefslogtreecommitdiff
path: root/bfd/vms-misc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-07-30 05:49:24 +0000
committerAlan Modra <amodra@gmail.com>2002-07-30 05:49:24 +0000
commit487e54f29acc5750992ab2e07574b872a32973ee (patch)
treedbbc9d8064271f0e56374706f78a69e1e05debd4 /bfd/vms-misc.c
parent9d46020e53ef3b47c3b9fa90d4f93410f233d3d7 (diff)
downloadgdb-487e54f29acc5750992ab2e07574b872a32973ee.zip
gdb-487e54f29acc5750992ab2e07574b872a32973ee.tar.gz
gdb-487e54f29acc5750992ab2e07574b872a32973ee.tar.bz2
* aoutx.h (some_aout_object_p): Clean up tdata properly on error.
* archive.c (bfd_generic_archive_p): Likewise. * coff-rs6000.c (_bfd_xcoff_archive_p): Likewise. (_bfd_xcoff_archive_p): Use bfd_scan_vma in place of strtol. * coff64-rs6000.c (xcoff64_slurp_armap): Likewise. (xcoff64_archive_p): Likewise. (xcoff64_openr_next_archived_file): Likewise. (xcoff64_archive_p): Clean up tdata properly on error. * coffgen.c (coff_real_object_p): Likewise. (coff_object_p): Release filehdr and opthdr. * ecoff.c (_bfd_ecoff_archive_p): Clean up tdata properly on error. * ieee.c (ieee_archive_p): Likewise. * ihex.c (ihex_object_p): Likewise. (ihex_mkobject): Always allocate tdata. * peicode.h (pe_ILF_object_p): Release bfd_alloc'd buffer on error. * srec.c (srec_mkobject): Always allocate tdata. (srec_object_p): Clean up tdata properly on error. (symbolsrec_object_p): Likewise. * versados.c (versados_object_p): Likewise. * vms-misc.c (_bfd_vms_get_record): Use bfd_malloc instead of malloc, and bfd_realloc instead of realloc. (add_new_contents): Use bfd_alloc instead of bfd_malloc for sections. * vms.c (vms_initialize): Always allocate tdata. Use bfd_alloc in place of bfd_malloc, simplifying error freeing. Free hash table too. (vms_object_p): Clean up tdata on error. (vms_mkobject): Don't complain on stderr if vms_initialize fails. (vms_close_and_cleanup): Adjust for bfd_alloc use.
Diffstat (limited to 'bfd/vms-misc.c')
-rw-r--r--bfd/vms-misc.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c
index b871a5d..3b043b4 100644
--- a/bfd/vms-misc.c
+++ b/bfd/vms-misc.c
@@ -292,23 +292,23 @@ _bfd_vms_get_record (abfd)
if (PRIV (buf_size) == 0)
{
+ bfd_size_type amt;
+
if (PRIV (is_vax))
{
- PRIV (vms_buf) = (unsigned char *) malloc (OBJ_S_C_MAXRECSIZ);
- PRIV (buf_size) = OBJ_S_C_MAXRECSIZ;
+ amt = OBJ_S_C_MAXRECSIZ;
PRIV (file_format) = FF_VAX;
}
else
- PRIV (vms_buf) = (unsigned char *) malloc (6);
+ amt = 6;
+ PRIV (vms_buf) = (unsigned char *) bfd_malloc (amt);
+ PRIV (buf_size) = amt;
}
vms_buf = PRIV (vms_buf);
if (vms_buf == 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return -1;
- }
+ return -1;
switch (PRIV (file_format))
{
@@ -371,7 +371,7 @@ _bfd_vms_get_record (abfd)
if (PRIV (is_vax))
{
PRIV (rec_length) = bfd_bread (vms_buf, (bfd_size_type) PRIV (buf_size),
- abfd);
+ abfd);
if (PRIV (rec_length) <= 0)
{
bfd_set_error (bfd_error_file_truncated);
@@ -383,7 +383,7 @@ _bfd_vms_get_record (abfd)
{
/* extract vms record length */
- _bfd_vms_get_header_values (abfd, vms_buf+test_start, NULL,
+ _bfd_vms_get_header_values (abfd, vms_buf + test_start, NULL,
&PRIV (rec_length));
if (PRIV (rec_length) <= 0)
@@ -405,13 +405,11 @@ _bfd_vms_get_record (abfd)
if (PRIV (rec_length) > PRIV (buf_size))
{
PRIV (vms_buf) = ((unsigned char *)
- realloc (vms_buf, (size_t) PRIV (rec_length)));
+ bfd_realloc (vms_buf,
+ (bfd_size_type) PRIV (rec_length)));
vms_buf = PRIV (vms_buf);
if (vms_buf == 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return -1;
- }
+ return -1;
PRIV (buf_size) = PRIV (rec_length);
}
@@ -593,7 +591,8 @@ add_new_contents (abfd, section)
if (sptr != NULL)
return sptr;
- newptr = (vms_section *) bfd_malloc ((bfd_size_type) sizeof (vms_section));
+ newptr = (vms_section *) bfd_alloc (abfd,
+ (bfd_size_type) sizeof (vms_section));
if (newptr == (vms_section *) NULL)
return NULL;
newptr->contents = (unsigned char *) bfd_alloc (abfd, section->_raw_size);