X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=libiberty%2Falloca.c;h=9b2e9cb12b63b494b2de76ba74ec9a04629e8202;hb=330f1d3825daa0d9e8d6c54f4fcf6fa5800e5664;hp=e98a053fbee5651f91af963b87d5109a90c749bd;hpb=99b581398536aae4ac5653df23c3d12d23359c1d;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/alloca.c b/libiberty/alloca.c index e98a053fbe..9b2e9cb12b 100644 --- a/libiberty/alloca.c +++ b/libiberty/alloca.c @@ -57,9 +57,15 @@ the possibility of a GCC built-in function. /* These variables are used by the ASTRDUP implementation that relies on C_alloca. */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ const char *libiberty_optr; char *libiberty_nptr; unsigned long libiberty_len; +#ifdef __cplusplus +} +#endif /* __cplusplus */ /* If your stack is a linked list of frames, you have to provide an "address metric" ADDRESS_FUNCTION macro. */ @@ -97,7 +103,7 @@ static int stack_dir; /* 1 or -1 once known. */ #define STACK_DIR stack_dir static void -find_stack_direction () +find_stack_direction (void) { static char *addr = NULL; /* Address of first `dummy', once known. */ auto char dummy; /* To get stack address. */ @@ -150,9 +156,10 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */ caller, but that method cannot be made to work for some implementations of C, for example under Gould's UTX/32. */ +/* @undocumented C_alloca */ + PTR -C_alloca (size) - size_t size; +C_alloca (size_t size) { auto char probe; /* Probes stack depth: */ register char *depth = ADDRESS_FUNCTION (probe); @@ -190,20 +197,20 @@ C_alloca (size) /* Allocate combined header + user data storage. */ { - register PTR new = xmalloc (sizeof (header) + size); + register void *new_storage = XNEWVEC (char, sizeof (header) + size); /* Address of header. */ - if (new == 0) + if (new_storage == 0) abort(); - ((header *) new)->h.next = last_alloca_header; - ((header *) new)->h.deep = depth; + ((header *) new_storage)->h.next = last_alloca_header; + ((header *) new_storage)->h.deep = depth; - last_alloca_header = (header *) new; + last_alloca_header = (header *) new_storage; /* User storage begins just after header. */ - return (PTR) ((char *) new + sizeof (header)); + return (PTR) ((char *) new_storage + sizeof (header)); } }