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.
This commit is contained in:
Alan Modra
2022-06-01 10:44:01 +09:30
parent 739f950664
commit b0de9ed86f
3 changed files with 41 additions and 7 deletions

View File

@ -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)
{