use bfd memory allcation routines

This commit is contained in:
Nick Clifton
1999-09-06 08:57:49 +00:00
parent d9ea9319a9
commit fed79cc616
2 changed files with 20 additions and 14 deletions

View File

@ -1,3 +1,8 @@
1999-09-06 Nick Clifton <nickc@cygnus.com>
* elflink.h (elf_gc_record_vtentry): Use bfd_zmalloc and
bfd_realloc instead of calloc and realloc.
1999-09-04 Steve Chamberlain <sac@pobox.com> 1999-09-04 Steve Chamberlain <sac@pobox.com>
* cpu-pj.c: New file. * cpu-pj.c: New file.

View File

@ -6419,30 +6419,31 @@ elf_gc_record_vtentry (abfd, sec, h, addend)
/* Allocate one extra entry for use as a "done" flag for the /* Allocate one extra entry for use as a "done" flag for the
consolidation pass. */ consolidation pass. */
bytes = (size / FILE_ALIGN + 1) * sizeof(boolean); bytes = (size / FILE_ALIGN + 1) * sizeof (boolean);
if (ptr) if (ptr)
{ {
size_t oldbytes; ptr = bfd_realloc (ptr - 1, bytes);
if (ptr != NULL)
{
size_t oldbytes;
ptr = realloc (ptr-1, bytes); oldbytes = (h->vtable_entries_size/FILE_ALIGN + 1) * sizeof (boolean);
if (ptr == NULL) memset (((char *)ptr) + oldbytes, 0, bytes - oldbytes);
return false; }
oldbytes = (h->vtable_entries_size/FILE_ALIGN + 1) * sizeof(boolean);
memset (((char *)ptr) + oldbytes, 0, bytes - oldbytes);
} }
else else
{ ptr = bfd_zmalloc (bytes);
ptr = calloc (1, bytes);
if (ptr == NULL)
return false;
}
if (ptr == NULL)
return false;
/* And arrange for that done flag to be at index -1. */ /* And arrange for that done flag to be at index -1. */
h->vtable_entries_used = ptr+1; h->vtable_entries_used = ptr + 1;
h->vtable_entries_size = size; h->vtable_entries_size = size;
} }
h->vtable_entries_used[addend / FILE_ALIGN] = true; h->vtable_entries_used[addend / FILE_ALIGN] = true;
return true; return true;