diff options
author | David MacKenzie <djm@cygnus> | 1994-02-05 02:46:12 +0000 |
---|---|---|
committer | David MacKenzie <djm@cygnus> | 1994-02-05 02:46:12 +0000 |
commit | 0ee3427297272a636e7ef8378182a38d64ed7b7d (patch) | |
tree | 4aad622fe6694ef2d197613a4c15a17d349507ee /bfd | |
parent | 0b2f8d2edd598eb8f013e8b61fd49def1d908281 (diff) | |
download | gdb-0ee3427297272a636e7ef8378182a38d64ed7b7d.zip gdb-0ee3427297272a636e7ef8378182a38d64ed7b7d.tar.gz gdb-0ee3427297272a636e7ef8378182a38d64ed7b7d.tar.bz2 |
* libbfd.c (bfd_zmalloc): Call bfd_xmalloc instead of malloc.
(bfd_xmalloc, bfd_xmalloc_by_size_t): Functions deleted.
* libbfd-in.h: Define them as macros calling xmalloc and declare
xmalloc.
* libbfd.h: Rebuilt.
* ecofflink.c hash.c ieee.c opncls.c (obstack_chunk_alloc): Define
to be xmalloc, not bfd_xmalloc_by_size_t.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 10 | ||||
-rw-r--r-- | bfd/ecofflink.c | 2 | ||||
-rw-r--r-- | bfd/hash.c | 4 | ||||
-rw-r--r-- | bfd/ieee.c | 2 | ||||
-rw-r--r-- | bfd/libbfd-in.h | 10 | ||||
-rw-r--r-- | bfd/libbfd.c | 55 | ||||
-rw-r--r-- | bfd/libbfd.h | 16 | ||||
-rw-r--r-- | bfd/opncls.c | 2 |
8 files changed, 37 insertions, 64 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 976140f..6e80994 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +Fri Feb 4 17:28:32 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * libbfd.c (bfd_zmalloc): Call bfd_xmalloc instead of malloc. + (bfd_xmalloc, bfd_xmalloc_by_size_t): Functions deleted. + * libbfd-in.h: Define them as macros calling xmalloc and declare + xmalloc. + * libbfd.h: Rebuilt. + * ecofflink.c hash.c ieee.c opncls.c (obstack_chunk_alloc): Define + to be xmalloc, not bfd_xmalloc_by_size_t. + Thu Feb 3 16:49:35 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) * ecofflink.c (bfd_ecoff_debug_externals): If a small undefined diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index 306f028..2f3235c 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -41,7 +41,7 @@ static boolean ecoff_write_symhdr PARAMS ((bfd *, struct ecoff_debug_info *, file_ptr where)); /* Obstack allocation and deallocation routines. */ -#define obstack_chunk_alloc bfd_xmalloc_by_size_t +#define obstack_chunk_alloc xmalloc #define obstack_chunk_free free /* The minimum amount of data to allocate. */ @@ -290,7 +290,7 @@ SUBSUBSECTION */ /* Obstack allocation and deallocation routines. */ -#define obstack_chunk_alloc bfd_xmalloc_by_size_t +#define obstack_chunk_alloc xmalloc #define obstack_chunk_free free /* The default number of entries to use when creating a hash table. */ @@ -419,7 +419,7 @@ bfd_hash_newfunc (entry, table, string) PTR bfd_hash_allocate (table, size) struct bfd_hash_table *table; - size_t size; + unsigned int size; { return obstack_alloc (&table->memory, size); } @@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "obstack.h" -#define obstack_chunk_alloc bfd_xmalloc_by_size_t +#define obstack_chunk_alloc xmalloc #define obstack_chunk_free free /* Functions for writing to ieee files in the strange way that the diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index a26046f..85d4998 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -73,7 +73,17 @@ struct areltdata { #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size) +/* There is major inconsistency in how running out of memory is handled. + Some routines return a NULL, and set bfd_error to no_memory. + However, obstack routines can't do this ... */ + char *bfd_zmalloc PARAMS ((bfd_size_type size)); +/* From libiberty. */ +extern PTR xmalloc PARAMS ((size_t)); +/* SIZE is bfd_size_type. */ +#define bfd_xmalloc(size) xmalloc ((size_t) size) +/* SIZE is size_t. */ +#define bfd_xmalloc_by_size_t(size) xmalloc (size) /* These routines allocate and free things on the BFD's obstack. Note that realloc can never occur in place. */ diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 0d6b5fc..29ebd09 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -132,65 +132,14 @@ char * bfd_zmalloc (size) bfd_size_type size; { - char *ptr = (char *) malloc ((size_t)size); + char *ptr = (char *) bfd_xmalloc (size); - if ((ptr != NULL) && (size != 0)) + if (size != 0) memset(ptr,0, (size_t) size); return ptr; } #endif /* bfd_zmalloc */ - -/* -INTERNAL_FUNCTION - bfd_xmalloc - -SYNOPSIS - PTR bfd_xmalloc (bfd_size_type size); - -DESCRIPTION - Like <<malloc>>, but exit if no more memory. - -*/ - -/** There is major inconsistency in how running out of memory is handled. - Some routines return a NULL, and set bfd_error to no_memory. - However, obstack routines can't do this ... */ - - -PTR -bfd_xmalloc (size) - bfd_size_type size; -{ - static CONST char no_memory_message[] = "Virtual memory exhausted!\n"; - PTR ptr; - if (size == 0) size = 1; - ptr = (PTR)malloc((size_t) size); - if (!ptr) - { - write (2, no_memory_message, sizeof(no_memory_message)-1); - exit (1); - } - return ptr; -} - -/* -INTERNAL_FUNCTION - bfd_xmalloc_by_size_t - -SYNOPSIS - PTR bfd_xmalloc_by_size_t (size_t size); - -DESCRIPTION - Like <<malloc>>, but exit if no more memory. - Uses <<size_t>>, so it's suitable for use as <<obstack_chunk_alloc>>. - */ -PTR -bfd_xmalloc_by_size_t (size) - size_t size; -{ - return bfd_xmalloc ((bfd_size_type) size); -} /* Some IO code */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index ed8464b..8babcf3 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -73,7 +73,17 @@ struct areltdata { #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size) +/* There is major inconsistency in how running out of memory is handled. + Some routines return a NULL, and set bfd_error to no_memory. + However, obstack routines can't do this ... */ + char *bfd_zmalloc PARAMS ((bfd_size_type size)); +/* From libiberty. */ +extern PTR xmalloc PARAMS ((size_t)); +/* SIZE is bfd_size_type. */ +#define bfd_xmalloc(size) xmalloc ((size_t) size) +/* SIZE is size_t. */ +#define bfd_xmalloc_by_size_t(size) xmalloc (size) /* These routines allocate and free things on the BFD's obstack. Note that realloc can never occur in place. */ @@ -260,12 +270,6 @@ extern bfd_target *bfd_default_vector[]; void bfd_check_init PARAMS ((void)); -PTR -bfd_xmalloc PARAMS ((bfd_size_type size)); - -PTR -bfd_xmalloc_by_size_t PARAMS ((size_t size)); - void bfd_write_bigendian_4byte_int PARAMS ((bfd *abfd, int i)); diff --git a/bfd/opncls.c b/bfd/opncls.c index 5c958c8..ddddf93 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -29,7 +29,7 @@ FILE *bfd_open_file PARAMS ((bfd *)); if we do that we can't use fcntl. */ -#define obstack_chunk_alloc bfd_xmalloc_by_size_t +#define obstack_chunk_alloc xmalloc #define obstack_chunk_free free /* Return a new BFD. All BFD's are allocated through this routine. */ |