aboutsummaryrefslogtreecommitdiff
path: root/bfd/doc
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-06-01 10:44:01 +0930
committerAlan Modra <amodra@gmail.com>2022-06-01 10:52:05 +0930
commitb0de9ed86f3af84fbd636f94a58b9c4ad7f4e743 (patch)
tree6e69a103f03c961e2b8532cc0898212929311a19 /bfd/doc
parent739f950664220bca1dbfa1cac56eafa16ea2c782 (diff)
downloadgdb-b0de9ed86f3af84fbd636f94a58b9c4ad7f4e743.zip
gdb-b0de9ed86f3af84fbd636f94a58b9c4ad7f4e743.tar.gz
gdb-b0de9ed86f3af84fbd636f94a58b9c4ad7f4e743.tar.bz2
Re: use libiberty xmalloc in bfd/doc/chew.c
We can't use libiberty.a in chew. libiberty is a host library, chew a build program. Partly revert commit 7273d78f3f7a, instead define local versions of the libiberty functions. ansidecl.h also isn't needed. * doc/chew.c: Don't include libiberty.h or ansidecl.h. (xmalloc, xrealloc, xstrdup): New functions. * doc/local.mk (LIBIBERTY): Don't define or use. * Makefile.in: Regenerate.
Diffstat (limited to 'bfd/doc')
-rw-r--r--bfd/doc/chew.c41
-rw-r--r--bfd/doc/local.mk4
2 files changed, 40 insertions, 5 deletions
diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c
index a12c003..1695173 100644
--- a/bfd/doc/chew.c
+++ b/bfd/doc/chew.c
@@ -81,8 +81,6 @@
Foo. */
-#include "ansidecl.h"
-#include "libiberty.h"
#include <assert.h>
#include <stdio.h>
#include <ctype.h>
@@ -145,6 +143,45 @@ die (char *msg)
exit (1);
}
+void *
+xmalloc (size_t size)
+{
+ void *newmem;
+
+ if (size == 0)
+ size = 1;
+ newmem = malloc (size);
+ if (!newmem)
+ die ("out of memory");
+
+ return newmem;
+}
+
+void *
+xrealloc (void *oldmem, size_t size)
+{
+ void *newmem;
+
+ if (size == 0)
+ size = 1;
+ if (!oldmem)
+ newmem = malloc (size);
+ else
+ newmem = realloc (oldmem, size);
+ if (!newmem)
+ die ("out of memory");
+
+ return newmem;
+}
+
+char *
+xstrdup (const char *s)
+{
+ size_t len = strlen (s) + 1;
+ char *ret = xmalloc (len);
+ return memcpy (ret, s, len);
+}
+
static void
init_string_with_size (string_type *buffer, unsigned int size)
{
diff --git a/bfd/doc/local.mk b/bfd/doc/local.mk
index 8c69328..931942f 100644
--- a/bfd/doc/local.mk
+++ b/bfd/doc/local.mk
@@ -82,14 +82,12 @@ TEXI2DVI = texi2dvi -I "$(srcdir)/%D%" -I %D%
MKDOC = %D%/chew$(EXEEXT_FOR_BUILD)
-LIBIBERTY = ../libiberty/libiberty.a
-
$(MKDOC): %D%/chew.stamp ; @true
%D%/chew.stamp: $(srcdir)/%D%/chew.c %D%/$(am__dirstamp)
$(AM_V_CCLD)$(CC_FOR_BUILD) -o %D%/chw$$$$$(EXEEXT_FOR_BUILD) $(CFLAGS_FOR_BUILD) \
$(LDFLAGS_FOR_BUILD) $(H_CFLAGS) \
-I. -I$(srcdir) -I%D% -I$(srcdir)/../include -I$(srcdir)/../intl -I../intl \
- $(srcdir)/%D%/chew.c $(LIBIBERTY) && \
+ $(srcdir)/%D%/chew.c && \
$(SHELL) $(srcdir)/../move-if-change \
%D%/chw$$$$$(EXEEXT_FOR_BUILD) $(MKDOC) && \
touch $@