diff options
author | Ian Lance Taylor <ian@airs.com> | 1995-12-01 19:48:10 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1995-12-01 19:48:10 +0000 |
commit | 58142f101dd3256f4741f60a6b25672d79b91371 (patch) | |
tree | e7ca6dd97a327093be2076160bebd1baaf20d8a4 /bfd/ecofflink.c | |
parent | 2eec871057c921ceb38fb0b7f3cd78e84b700808 (diff) | |
download | gdb-58142f101dd3256f4741f60a6b25672d79b91371.zip gdb-58142f101dd3256f4741f60a6b25672d79b91371.tar.gz gdb-58142f101dd3256f4741f60a6b25672d79b91371.tar.bz2 |
* libbfd.c (bfd_malloc, bfd_realloc): New functions.
(bfd_zmalloc): Return PTR, not char *. Take size_t, not
bfd_size_type.
* libbfd-in.h (bfd_malloc, bfd_realloc): Declare.
(bfd_zmalloc): Change declaration.
* libbfd.h: Rebuild.
* Many files: Use bfd_malloc and bfd_realloc rather than malloc
and realloc. Don't set bfd_error_no_memory if they fail.
Diffstat (limited to 'bfd/ecofflink.c')
-rw-r--r-- | bfd/ecofflink.c | 66 |
1 files changed, 18 insertions, 48 deletions
diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index b8b0631..af84d20 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -270,15 +270,9 @@ ecoff_add_bytes (buf, bufend, need) if (want < ALLOC_SIZE) want = ALLOC_SIZE; } - if (*buf == NULL) - newbuf = (char *) malloc (have + want); - else - newbuf = (char *) realloc (*buf, have + want); + newbuf = (char *) bfd_realloc (*buf, have + want); if (newbuf == NULL) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; *buf = newbuf; *bufend = *buf + have + want; return true; @@ -503,12 +497,9 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info) { struct accumulate *ainfo; - ainfo = (struct accumulate *) malloc (sizeof (struct accumulate)); + ainfo = (struct accumulate *) bfd_malloc (sizeof (struct accumulate)); if (!ainfo) - { - bfd_set_error (bfd_error_no_memory); - return NULL; - } + return NULL; if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc, 1021)) return NULL; @@ -720,12 +711,9 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap, information that should not be merged. */ name = input_debug->ss + fdr.issBase + fdr.rss; - lookup = (char *) malloc (strlen (name) + 20); + lookup = (char *) bfd_malloc (strlen (name) + 20); if (lookup == NULL) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; sprintf (lookup, "%s %lx", name, fdr.csym); fh = string_hash_lookup (&ainfo->fdr_hash, lookup, true, true); @@ -1558,12 +1546,9 @@ ecoff_write_symhdr (abfd, debug, swap, where) SET (cbExtOffset, iextMax, swap->external_ext_size); #undef SET - buff = (PTR) malloc ((size_t) swap->external_hdr_size); + buff = (PTR) bfd_malloc ((size_t) swap->external_hdr_size); if (buff == NULL && swap->external_hdr_size != 0) - { - bfd_set_error (bfd_error_no_memory); - goto error_return; - } + goto error_return; (*swap->swap_hdr_out) (abfd, symhdr, buff); if (bfd_write (buff, 1, swap->external_hdr_size, abfd) @@ -1660,12 +1645,9 @@ ecoff_write_shuffle (abfd, swap, shuffle, space) bfd_byte *s; i = swap->debug_align - (total & (swap->debug_align - 1)); - s = (bfd_byte *) malloc (i); + s = (bfd_byte *) bfd_malloc (i); if (s == NULL && i != 0) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; memset ((PTR) s, 0, i); if (bfd_write ((PTR) s, 1, i, abfd) != i) @@ -1697,12 +1679,9 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) if (! ecoff_write_symhdr (abfd, debug, swap, where)) goto error_return; - space = (PTR) malloc (ainfo->largest_file_shuffle); + space = (PTR) bfd_malloc (ainfo->largest_file_shuffle); if (space == NULL && ainfo->largest_file_shuffle != 0) - { - bfd_set_error (bfd_error_no_memory); - goto error_return; - } + goto error_return; if (! ecoff_write_shuffle (abfd, swap, ainfo->line, space) || ! ecoff_write_shuffle (abfd, swap, ainfo->pdr, space) @@ -1749,12 +1728,9 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) bfd_byte *s; i = swap->debug_align - (total & (swap->debug_align - 1)); - s = (bfd_byte *) malloc (i); + s = (bfd_byte *) bfd_malloc (i); if (s == NULL && i != 0) - { - bfd_set_error (bfd_error_no_memory); - goto error_return; - } + goto error_return; memset ((PTR) s, 0, i); if (bfd_write ((PTR) s, 1, i, abfd) != i) { @@ -1777,12 +1753,9 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) i = (swap->debug_align - (debug->symbolic_header.issExtMax & (swap->debug_align - 1))); - s = (bfd_byte *) malloc (i); + s = (bfd_byte *) bfd_malloc (i); if (s == NULL && i != 0) - { - bfd_set_error (bfd_error_no_memory); - goto error_return; - } + goto error_return; memset ((PTR) s, 0, i); if (bfd_write ((PTR) s, 1, i, abfd) != i) { @@ -2352,12 +2325,9 @@ _bfd_ecoff_locate_line (abfd, section, offset, debug_info, debug_swap, { if (line_info->find_buffer != NULL) free (line_info->find_buffer); - buffer = (char *) malloc (len); + buffer = (char *) bfd_malloc (len); if (buffer == NULL) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; line_info->find_buffer = buffer; } |