/* Assorted BFD support routines, only used internally.
- Copyright (C) 1990-2019 Free Software Foundation, Inc.
+ Copyright (C) 1990-2020 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
return 0;
}
-const bfd_target *
+bfd_cleanup
_bfd_dummy_target (bfd *ignore_abfd ATTRIBUTE_UNUSED)
{
bfd_set_error (bfd_error_wrong_format);
return ptr;
}
-/* Allocate memory using malloc, nmemb * size with overflow checking. */
-
-void *
-bfd_malloc2 (bfd_size_type nmemb, bfd_size_type size)
-{
- if ((nmemb | size) >= HALF_BFD_SIZE_TYPE
- && size != 0
- && nmemb > ~(bfd_size_type) 0 / size)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
-
- return bfd_malloc (size * nmemb);
-}
-
-/* Reallocate memory using realloc. */
-
void *
bfd_realloc (void *ptr, bfd_size_type size)
{
return ret;
}
-/* Reallocate memory using realloc, nmemb * size with overflow checking. */
-
-void *
-bfd_realloc2 (void *ptr, bfd_size_type nmemb, bfd_size_type size)
-{
- if ((nmemb | size) >= HALF_BFD_SIZE_TYPE
- && size != 0
- && nmemb > ~(bfd_size_type) 0 / size)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
-
- return bfd_realloc (ptr, size * nmemb);
-}
-
/* Reallocate memory using realloc.
If this fails the pointer is freed before returning. */
{
void *ret = bfd_realloc (ptr, size);
- if (ret == NULL && ptr != NULL)
+ if (ret == NULL)
free (ptr);
return ret;
return ptr;
}
-/* Allocate memory using malloc (nmemb * size) with overflow checking
- and clear it. */
-
-void *
-bfd_zmalloc2 (bfd_size_type nmemb, bfd_size_type size)
-{
- void *ptr = bfd_malloc2 (nmemb, size);
-
- if (ptr != NULL)
- {
- size_t sz = nmemb * size;
-
- if (sz > 0)
- memset (ptr, 0, sz);
- }
-
- return ptr;
-}
-
/*
INTERNAL_FUNCTION
bfd_write_bigendian_4byte_int
. BFD_SEND (abfd, bfd_getx_signed_64, (ptr))
.
.#define bfd_get(bits, abfd, ptr) \
-. ((bits) == 8 ? (bfd_vma) bfd_get_8 (abfd, ptr) \
+. ((bits) == 8 ? bfd_get_8 (abfd, ptr) \
. : (bits) == 16 ? bfd_get_16 (abfd, ptr) \
. : (bits) == 32 ? bfd_get_32 (abfd, ptr) \
. : (bits) == 64 ? bfd_get_64 (abfd, ptr) \