mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 22:48:57 +08:00
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:
@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user