aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd.c
diff options
context:
space:
mode:
authorJohn Gilmore <gnu@cygnus>1991-11-22 16:22:01 +0000
committerJohn Gilmore <gnu@cygnus>1991-11-22 16:22:01 +0000
commit1e310759ec18700f0e14ad466b51f8586cc07d41 (patch)
tree7d29d98047a41a14c1c1976e5d6bc9244e7641cf /bfd/libbfd.c
parentf39eae7baa17c6653aa625d201bf303bfc1592e8 (diff)
downloadgdb-1e310759ec18700f0e14ad466b51f8586cc07d41.zip
gdb-1e310759ec18700f0e14ad466b51f8586cc07d41.tar.gz
gdb-1e310759ec18700f0e14ad466b51f8586cc07d41.tar.bz2
Lint
Diffstat (limited to 'bfd/libbfd.c')
-rw-r--r--bfd/libbfd.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 0d957dc..394ac5e 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -124,6 +124,31 @@ DEFUN(zalloc,(size),
return ptr;
}
#endif
+
+/*proto-internal* bfd_xmalloc
+bfd_xmalloc -- Like malloc, but exit if no more memory.
+*; PROTO(PTR, bfd_xmalloc,( bfd_size_type 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 ... */
+
+
+DEFUN(PTR bfd_xmalloc,(size),
+ bfd_size_type size)
+{
+ static char no_memory_message[] = "Virtual memory exhausted!\n";
+ PTR ptr;
+ if (size == 0) size = 1;
+ ptr = (PTR)malloc(size);
+ if (ptr == NULL)
+ if (!ptr)
+ {
+ write (2, no_memory_message, sizeof(no_memory_message)-1);
+ exit (-1);
+ }
+ return ptr;
+}
/* Some IO code */
@@ -164,14 +189,18 @@ DEFUN(bfd_write,(ptr, size, nitems, abfd),
return fwrite (ptr, 1, (int)(size*nitems), bfd_cache_lookup(abfd));
}
+/*proto-internal* bfd_write_bigendian_4byte_int
+
+*; PROTO(void, bfd_write_bigendian_4byte_int,( bfd *abfd, int i));
+*/
void
DEFUN(bfd_write_bigendian_4byte_int,(abfd, i),
bfd *abfd AND
int i)
{
- char buffer[4];
+ bfd_byte buffer[4];
_do_putb32(i, buffer);
- bfd_write(buffer, 4, 1, abfd);
+ bfd_write((PTR)buffer, 4, 1, abfd);
}
int