+2005-05-24 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ * libiberty.h (ACONCAT): Properly cast value of alloca().
+
+ * ansidecl.h (ATTRIBUTE_UNUSED_LABEL): Don't define if
+ __cplusplus.
+
2005-05-12 Steve Ellcey <sje@cup.hp.com>
libiberty.h: Do not define empty basename prototype.
/* Attributes on labels were valid as of gcc 2.93. */
#ifndef ATTRIBUTE_UNUSED_LABEL
-# if (GCC_VERSION >= 2093)
+# if (!defined (__cplusplus) && GCC_VERSION >= 2093)
# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
# else
# define ATTRIBUTE_UNUSED_LABEL
-# endif /* GNUC >= 2.93 */
+# endif /* !__cplusplus && GNUC >= 2.93 */
#endif /* ATTRIBUTE_UNUSED_LABEL */
#ifndef ATTRIBUTE_UNUSED
strings. Allocates memory using alloca. The arguments are
evaluated twice! */
#define ACONCAT(ACONCAT_PARAMS) \
- (libiberty_concat_ptr = alloca (concat_length ACONCAT_PARAMS + 1), \
+ (libiberty_concat_ptr = (char *) alloca (concat_length ACONCAT_PARAMS + 1), \
concat_copy2 ACONCAT_PARAMS)
/* Check whether two file descriptors refer to the same file. */
+2005-05-24 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ * configure.ac: Check declarations for calloc(), getenv(),
+ malloc(), realloc() and sbrk().
+ * config.in: Regenerate.
+ * configure: Likewise.
+
+ * alloca.c (C_alloca): Change "new" to "new_storage". Use XNEWVEC
+ instead of xmalloc.
+ * choose-temp.c (choose_temp_base): Use XNEWVEC instea od xmalloc.
+ * concat.c (liiberty_concat_ptr): Surround definition with an
+ extern "C" block, if __cplusplus.
+ (concat): Use XNEWVEC instead of xmalloc.
+ (reconcat): Likewise.
+ * cp-demangle.c (struct d_print_template): Rename member
+ "template" to "template_decl". Adjust use throughout the file.
+ (d_print_resize): Properly cast return value of realloc().
+ (cplus_demangle_print): Same for malloc().
+ (d_demangle): Likewise.
+ * cp-demint.c (cplus_demangle_fill_builtin_type): Rename parameter
+ "typename" to "type_name".
+ * cplus-dem.c (grow_vect): Use XRESIZEVEC instead of xrealloc().
+ (work_stuff_copy_to_from): Use XNEWVEC insteand of xmalloc().
+ (demangle_template_value_parm): Likewise.
+ (demangle_template): Likewise.
+ (recursively_demangle): Likewise.
+ (do_hpacc_template_literal): Likewise.
+ (do_arg): Likewise.
+ (remember_type): Likewise.
+ (remember_Ktype): Likewise.
+ (register_Btype): Likewise.
+ (string_need): Use XRESIZEVEC instead of xrealloc().
+ * dyn-string.c (dyn_string_init): Use XNEWVEC.
+ (dyn_string_new): Use XNEW.
+ (dyn_string_resize): Use XRESIZEVEC.
+ * fnmatch.c (fnmatch): Rename local variable "not" to "negate".
+ * getopt.c (getenv): Declare only if !__cplusplus and !getenv.
+ Otherwise include <stdlib.h>.
+ (exchange): Cast return value of malloc().
+ * hashtab.c (htab_size): Define as both macro and non-inline
+ function.
+ (htab_elements): Likewise.
+ * getpwd.c (getpwd): Use XNEWVEC.
+ (htab_create_alloc_ex): Use C90 prototype-style.
+ * lrealpath.c (lrealpath): Appropriately cast return value of
+ malloc().
+ * make-relative-prefix.c (save_string): Likewise.
+ * make-temp-file.c (try_dir): Rename from "try". Adjust use in
+ the file.
+ (choose_tmpdir): Use XNEWVEC.
+ * mkstemps.c (mkstemps): Rename parameter "template" to "pattern".
+ * pex-common.c (pex_init_common): Use XNEW.
+ (pex_add_remove): Use XRESIZEVEC.
+ (pex_run): Likewise.
+ (pex_get_status_and_time): Likewise.
+ * pex-djgpp.c (pex_djgpp_exec_child): Likewise.
+ * pex-msdos.c (pex_init): Use XNEW.
+ (pex_msdos_exec_child): Likewise.
+ (pex_msdos_exec_child): Use XRESIZEVEC.
+ * pex-unix.c (pex_wait): Use XNEW.
+ * pex-win32.c (fix_argv): Use XNEWVEC.
+ * pexecute.c (pwait): Likewise.
+ * setenv.c (setenv): Properly cast return value of malloc().
+ * sigsetmask.c (sigsetmask): Rename local variables "old" and
+ "new" to "old_sig" and "new_sig".
+ * sort.c (main): Use XNEWVEC.
+ * spaces.c (spaces): Cast return value of malloc().
+ * strndup.c (strndup): Likewise.
+ * ternary.c (ternary_insert): Use XNEW.
+ * xmalloc.c (malloc, realloc, calloc, sbrk): Surround declaration
+ with an extern "C" block if __cplusplus.
+ * xstrdup.c (xstrdup): Cast return value of memcpy().
+ * xstrerror.c (strerror): Enclose declaration in an extern "C"
+ block if __cplusplus.
+ * xstrndup.c (xstrndup): Use XNEW. Cast return value of memcpy().
+
2005-05-16 Andreas Jaeger <aj@suse.de>
* getpwd.c: Remove unneeded prototype getcwd and move getwd so
/* 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. */
/* 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));
}
}
int len;
len = strlen (base);
- temp_filename = xmalloc (len + TEMP_FILE_LEN + 1);
+ temp_filename = XNEWVEC (char, len + TEMP_FILE_LEN + 1);
strcpy (temp_filename, base);
strcpy (temp_filename + len, TEMP_FILE);
return save_dst;
}
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
char *libiberty_concat_ptr;
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
/* @undocumented concat_copy2 */
/* First compute the size of the result and get sufficient memory. */
VA_OPEN (args, first);
VA_FIXEDARG (args, const char *, first);
- newstr = (char *) xmalloc (vconcat_length (first, args) + 1);
+ newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
VA_CLOSE (args);
/* Now copy the individual pieces to the result string. */
VA_OPEN (args, first);
VA_FIXEDARG (args, char *, optr);
VA_FIXEDARG (args, const char *, first);
- newstr = (char *) xmalloc (vconcat_length (first, args) + 1);
+ newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
VA_CLOSE (args);
/* Now copy the individual pieces to the result string. */
don't. */
#undef HAVE_DECL_BASENAME
+/* Define to 1 if you have the declaration of `calloc', and to 0 if you don't.
+ */
+#undef HAVE_DECL_CALLOC
+
/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
#undef HAVE_DECL_FFS
+/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't.
+ */
+#undef HAVE_DECL_GETENV
+
+/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't.
+ */
+#undef HAVE_DECL_MALLOC
+
+/* Define to 1 if you have the declaration of `realloc', and to 0 if you
+ don't. */
+#undef HAVE_DECL_REALLOC
+
+/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't.
+ */
+#undef HAVE_DECL_SBRK
+
/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
don't. */
#undef HAVE_DECL_VASPRINTF
_ACEOF
+fi
+
+
+ echo "$as_me:$LINENO: checking whether calloc is declared" >&5
+echo $ECHO_N "checking whether calloc is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_calloc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef calloc
+ char *p = (char *) calloc;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_calloc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_calloc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_calloc" >&5
+echo "${ECHO_T}$ac_cv_have_decl_calloc" >&6
+if test $ac_cv_have_decl_calloc = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_CALLOC 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_CALLOC 0
+_ACEOF
+
+
+fi
+echo "$as_me:$LINENO: checking whether getenv is declared" >&5
+echo $ECHO_N "checking whether getenv is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_getenv+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef getenv
+ char *p = (char *) getenv;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_getenv=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_getenv=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_getenv" >&5
+echo "${ECHO_T}$ac_cv_have_decl_getenv" >&6
+if test $ac_cv_have_decl_getenv = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETENV 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETENV 0
+_ACEOF
+
+
+fi
+echo "$as_me:$LINENO: checking whether malloc is declared" >&5
+echo $ECHO_N "checking whether malloc is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_malloc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef malloc
+ char *p = (char *) malloc;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_malloc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_malloc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_malloc" >&5
+echo "${ECHO_T}$ac_cv_have_decl_malloc" >&6
+if test $ac_cv_have_decl_malloc = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MALLOC 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MALLOC 0
+_ACEOF
+
+
+fi
+echo "$as_me:$LINENO: checking whether realloc is declared" >&5
+echo $ECHO_N "checking whether realloc is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_realloc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef realloc
+ char *p = (char *) realloc;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_realloc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_realloc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_realloc" >&5
+echo "${ECHO_T}$ac_cv_have_decl_realloc" >&6
+if test $ac_cv_have_decl_realloc = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_REALLOC 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_REALLOC 0
+_ACEOF
+
+
+fi
+echo "$as_me:$LINENO: checking whether sbrk is declared" >&5
+echo $ECHO_N "checking whether sbrk is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_sbrk+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef sbrk
+ char *p = (char *) sbrk;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_sbrk=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_sbrk=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_sbrk" >&5
+echo "${ECHO_T}$ac_cv_have_decl_sbrk" >&6
+if test $ac_cv_have_decl_sbrk = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SBRK 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SBRK 0
+_ACEOF
+
+
fi
AC_CHECK_FUNCS($checkfuncs)
AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf])
+ AC_CHECK_DECLS([calloc, getenv, malloc, realloc, sbrk])
libiberty_NEED_DECLARATION(canonicalize_file_name)
fi
/* Next template on the list. */
struct d_print_template *next;
/* This template. */
- const struct demangle_component *template;
+ const struct demangle_component *template_decl;
};
/* A list of type modifiers. This is used while printing. */
char *newbuf;
newalc = dpi->alc * 2;
- newbuf = realloc (dpi->buf, newalc);
+ newbuf = (char *) realloc (dpi->buf, newalc);
if (newbuf == NULL)
{
free (dpi->buf);
dpi.options = options;
dpi.alc = estimate + 1;
- dpi.buf = malloc (dpi.alc);
+ dpi.buf = (char *) malloc (dpi.alc);
if (dpi.buf == NULL)
{
*palc = 1;
{
dpt.next = dpi->templates;
dpi->templates = &dpt;
- dpt.template = typed_name;
+ dpt.template_decl = typed_name;
}
/* If typed_name is a DEMANGLE_COMPONENT_LOCAL_NAME, then
return;
}
i = dc->u.s_number.number;
- for (a = d_right (dpi->templates->template);
+ for (a = d_right (dpi->templates->template_decl);
a != NULL;
a = d_right (a))
{
dpt.next = dpi->templates;
dpi->templates = &dpt;
- dpt.template = d_left (dc);
+ dpt.template_decl = d_left (dc);
d_print_comp (dpi, d_left (d_left (dc)));
{
char *r;
- r = malloc (40 + len - 11);
+ r = (char *) malloc (40 + len - 11);
if (r == NULL)
*palc = 1;
else
int
cplus_demangle_fill_builtin_type (struct demangle_component *p,
- const char *typename)
+ const char *type_name)
{
int len;
unsigned int i;
- if (p == NULL || typename == NULL)
+ if (p == NULL || type_name == NULL)
return 0;
- len = strlen (typename);
+ len = strlen (type_name);
for (i = 0; i < D_BUILTIN_TYPE_COUNT; ++i)
{
if (len == cplus_demangle_builtin_types[i].len
- && strcmp (typename, cplus_demangle_builtin_types[i].name) == 0)
+ && strcmp (type_name, cplus_demangle_builtin_types[i].name) == 0)
{
p->type = DEMANGLE_COMPONENT_BUILTIN_TYPE;
p->u.s_builtin.type = &cplus_demangle_builtin_types[i];
*size *= 2;
if (*size < min_size)
*size = min_size;
- *old_vect = (void *) xrealloc (*old_vect, *size * element_size);
+ *old_vect = XRESIZEVAR (char, *old_vect, *size * element_size);
}
}
/* Deep-copy dynamic storage. */
if (from->typevec_size)
- to->typevec
- = (char **) xmalloc (from->typevec_size * sizeof (to->typevec[0]));
+ to->typevec = XNEWVEC (char *, from->typevec_size);
for (i = 0; i < from->ntypes; i++)
{
int len = strlen (from->typevec[i]) + 1;
- to->typevec[i] = xmalloc (len);
+ to->typevec[i] = XNEWVEC (char, len);
memcpy (to->typevec[i], from->typevec[i], len);
}
if (from->ksize)
- to->ktypevec
- = (char **) xmalloc (from->ksize * sizeof (to->ktypevec[0]));
+ to->ktypevec = XNEWVEC (char *, from->ksize);
for (i = 0; i < from->numk; i++)
{
int len = strlen (from->ktypevec[i]) + 1;
- to->ktypevec[i] = xmalloc (len);
+ to->ktypevec[i] = XNEWVEC (char, len);
memcpy (to->ktypevec[i], from->ktypevec[i], len);
}
if (from->bsize)
- to->btypevec
- = (char **) xmalloc (from->bsize * sizeof (to->btypevec[0]));
+ to->btypevec = XNEWVEC (char *, from->bsize);
for (i = 0; i < from->numb; i++)
{
int len = strlen (from->btypevec[i]) + 1;
- to->btypevec[i] = xmalloc (len);
+ to->btypevec[i] = XNEWVEC (char , len);
memcpy (to->btypevec[i], from->btypevec[i], len);
}
if (from->ntmpl_args)
- to->tmpl_argvec
- = (char **) xmalloc (from->ntmpl_args * sizeof (to->tmpl_argvec[0]));
+ to->tmpl_argvec = XNEWVEC (char *, from->ntmpl_args);
for (i = 0; i < from->ntmpl_args; i++)
{
int len = strlen (from->tmpl_argvec[i]) + 1;
- to->tmpl_argvec[i] = xmalloc (len);
+ to->tmpl_argvec[i] = XNEWVEC (char, len);
memcpy (to->tmpl_argvec[i], from->tmpl_argvec[i], len);
}
if (from->previous_argument)
{
- to->previous_argument = (string*) xmalloc (sizeof (string));
+ to->previous_argument = XNEW (string);
string_init (to->previous_argument);
string_appends (to->previous_argument, from->previous_argument);
}
string_appendn (s, "0", 1);
else
{
- char *p = xmalloc (symbol_len + 1), *q;
+ char *p = XNEWVEC (char, symbol_len + 1), *q;
strncpy (p, *mangled, symbol_len);
p [symbol_len] = '\0';
/* We use cplus_demangle here, rather than
if (!is_type)
{
/* Create an array for saving the template argument values. */
- work->tmpl_argvec = (char**) xmalloc (r * sizeof (char *));
+ work->tmpl_argvec = XNEWVEC (char *, r);
work->ntmpl_args = r;
for (i = 0; i < r; i++)
work->tmpl_argvec[i] = 0;
{
/* Save the template argument. */
int len = temp.p - temp.b;
- work->tmpl_argvec[i] = xmalloc (len + 1);
+ work->tmpl_argvec[i] = XNEWVEC (char, len + 1);
memcpy (work->tmpl_argvec[i], temp.b, len);
work->tmpl_argvec[i][len] = '\0';
}
{
/* Save the template argument. */
int len = r2;
- work->tmpl_argvec[i] = xmalloc (len + 1);
+ work->tmpl_argvec[i] = XNEWVEC (char, len + 1);
memcpy (work->tmpl_argvec[i], *mangled, len);
work->tmpl_argvec[i][len] = '\0';
}
if (!is_type)
{
int len = s->p - s->b;
- work->tmpl_argvec[i] = xmalloc (len + 1);
+ work->tmpl_argvec[i] = XNEWVEC (char, len + 1);
memcpy (work->tmpl_argvec[i], s->b, len);
work->tmpl_argvec[i][len] = '\0';
char * recurse = (char *)NULL;
char * recurse_dem = (char *)NULL;
- recurse = (char *) xmalloc (namelength + 1);
+ recurse = XNEWVEC (char, namelength + 1);
memcpy (recurse, *mangled, namelength);
recurse[namelength] = '\000';
string_append (result, "&");
/* Now recursively demangle the literal name */
- recurse = (char *) xmalloc (literal_len + 1);
+ recurse = XNEWVEC (char, literal_len + 1);
memcpy (recurse, *mangled, literal_len);
recurse[literal_len] = '\000';
if (work->previous_argument)
string_delete (work->previous_argument);
else
- work->previous_argument = (string*) xmalloc (sizeof (string));
+ work->previous_argument = XNEW (string);
if (!do_type (work, mangled, work->previous_argument))
return 0;
if (work -> typevec_size == 0)
{
work -> typevec_size = 3;
- work -> typevec
- = (char **) xmalloc (sizeof (char *) * work -> typevec_size);
+ work -> typevec = XNEWVEC (char *, work->typevec_size);
}
else
{
work -> typevec_size *= 2;
work -> typevec
- = (char **) xrealloc ((char *)work -> typevec,
- sizeof (char *) * work -> typevec_size);
+ = XRESIZEVEC (char *, work->typevec, work->typevec_size);
}
}
- tem = xmalloc (len + 1);
+ tem = XNEWVEC (char, len + 1);
memcpy (tem, start, len);
tem[len] = '\0';
work -> typevec[work -> ntypes++] = tem;
if (work -> ksize == 0)
{
work -> ksize = 5;
- work -> ktypevec
- = (char **) xmalloc (sizeof (char *) * work -> ksize);
+ work -> ktypevec = XNEWVEC (char *, work->ksize);
}
else
{
work -> ksize *= 2;
work -> ktypevec
- = (char **) xrealloc ((char *)work -> ktypevec,
- sizeof (char *) * work -> ksize);
+ = XRESIZEVEC (char *, work->ktypevec, work->ksize);
}
}
- tem = xmalloc (len + 1);
+ tem = XNEWVEC (char, len + 1);
memcpy (tem, start, len);
tem[len] = '\0';
work -> ktypevec[work -> numk++] = tem;
if (work -> bsize == 0)
{
work -> bsize = 5;
- work -> btypevec
- = (char **) xmalloc (sizeof (char *) * work -> bsize);
+ work -> btypevec = XNEWVEC (char *, work->bsize);
}
else
{
work -> bsize *= 2;
work -> btypevec
- = (char **) xrealloc ((char *)work -> btypevec,
- sizeof (char *) * work -> bsize);
+ = XRESIZEVEC (char *, work->btypevec, work->bsize);
}
}
ret = work -> numb++;
{
char *tem;
- tem = xmalloc (len + 1);
+ tem = XNEWVEC (char, len + 1);
memcpy (tem, start, len);
tem[len] = '\0';
work -> btypevec[index] = tem;
{
n = 32;
}
- s->p = s->b = xmalloc (n);
+ s->p = s->b = XNEWVEC (char, n);
s->e = s->b + n;
}
else if (s->e - s->p < n)
tem = s->p - s->b;
n += tem;
n *= 2;
- s->b = xrealloc (s->b, n);
+ s->b = XRESIZEVEC (char, s->b, n);
s->p = s->b + tem;
s->e = s->b + n;
}
if (ds_struct_ptr->s == NULL)
return 0;
#else
- ds_struct_ptr->s = (char *) xmalloc (space);
+ ds_struct_ptr->s = XNEWVEC (char, space);
#endif
ds_struct_ptr->allocated = space;
ds_struct_ptr->length = 0;
return NULL;
}
#else
- result = (dyn_string_t) xmalloc (sizeof (struct dyn_string));
+ result = XNEW (struct dyn_string);
dyn_string_init (result, space);
#endif
return result;
return NULL;
}
#else
- ds->s = (char *) xrealloc (ds->s, ds->allocated);
+ ds->s = XRESIZEVEC (char, ds->s, ds->allocated);
#endif
}
case '[':
{
/* Nonzero if the sense of the character class is inverted. */
- register int not;
+ register int negate;
if (*n == '\0')
return FNM_NOMATCH;
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
- not = (*p == '!' || *p == '^');
- if (not)
+ negate = (*p == '!' || *p == '^');
+ if (negate)
++p;
c = *p++;
if (c == ']')
break;
}
- if (!not)
+ if (!negate)
return FNM_NOMATCH;
break;
/* XXX 1003.2d11 is unclear if this is right. */
++p;
}
- if (not)
+ if (negate)
return FNM_NOMATCH;
}
break;
/* Avoid depending on library functions or files
whose names are inconsistent. */
-#ifndef getenv
-extern char *getenv ();
+#if HAVE_STDLIB_H && HAVE_DECL_GETENV
+# include <stdlib.h>
+#elif !defined(getenv)
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
+extern char *getenv (const char *);
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
#endif
static char *
{
/* We must extend the array. The user plays games with us and
presents new arguments. */
- char *new_str = malloc (top + 1);
+ char *new_str = (char *) malloc (top + 1);
if (new_str == NULL)
nonoption_flags_len = nonoption_flags_max_len = 0;
else
&& dotstat.st_dev == pwdstat.st_dev))
/* The shortcut didn't work. Try the slow, ``sure'' way. */
- for (s = GUESSPATHLEN; ! getcwd (p = xmalloc (s), s); s *= 2)
+ for (s = GUESSPATHLEN; !getcwd (p = XNEWVEC (char, s), s); s *= 2)
{
int e = errno;
free (p);
static char *pwd = 0;
if (!pwd)
- pwd = getcwd (xmalloc (MAXPATHLEN + 1), MAXPATHLEN + 1
+ pwd = getcwd (XNEWVEC (char, MAXPATHLEN + 1), MAXPATHLEN + 1
#ifdef VMS
, 0
#endif
return p1 == p2;
}
-/* Return the current size of given hash table. */
-inline size_t
-htab_size (htab_t htab)
+/* The parens around the function names in the next two definitions
+ are essential in order to prevent macro expansions of the name.
+ The bodies, however, are expanded as expected, so they are not
+ recursive definitions. */
+
+/* Return the current size of given hash table. */
+
+#define htab_size(htab) ((htab)->size)
+
+size_t
+(htab_size) (htab_t htab)
{
- return htab->size;
+ return htab_size (htab);
}
/* Return the current number of elements in given hash table. */
-inline size_t
-htab_elements (htab_t htab)
+#define htab_elements(htab) ((htab)->n_elements - (htab)->n_deleted)
+
+size_t
+(htab_elements) (htab_t htab)
{
- return htab->n_elements - htab->n_deleted;
+ return htab_elements (htab);
}
/* Return X % Y. */
an extra argument. */
htab_t
-htab_create_alloc_ex (size, hash_f, eq_f, del_f, alloc_arg, alloc_f,
- free_f)
- size_t size;
- htab_hash hash_f;
- htab_eq eq_f;
- htab_del del_f;
- PTR alloc_arg;
- htab_alloc_with_arg alloc_f;
- htab_free_with_arg free_f;
+htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
+ htab_del del_f, void *alloc_arg,
+ htab_alloc_with_arg alloc_f,
+ htab_free_with_arg free_f)
{
htab_t result;
unsigned int size_prime_index;
{
/* PATH_MAX is bounded. */
char *buf, *rp, *ret;
- buf = malloc (path_max);
+ buf = (char *) malloc (path_max);
if (buf == NULL)
return NULL;
rp = realpath (filename, buf);
static char *
save_string (const char *s, int len)
{
- char *result = malloc (len + 1);
+ char *result = (char *) malloc (len + 1);
memcpy (result, s, len);
result[len] = 0;
If success, DIR is returned.
Otherwise NULL is returned. */
-static inline const char *try (const char *, const char *);
+static inline const char *try_dir (const char *, const char *);
static inline const char *
-try (const char *dir, const char *base)
+try_dir (const char *dir, const char *base)
{
if (base != 0)
return base;
if (memoized_tmpdir)
return memoized_tmpdir;
- base = try (getenv ("TMPDIR"), base);
- base = try (getenv ("TMP"), base);
- base = try (getenv ("TEMP"), base);
+ base = try_dir (getenv ("TMPDIR"), base);
+ base = try_dir (getenv ("TMP"), base);
+ base = try_dir (getenv ("TEMP"), base);
#ifdef P_tmpdir
- base = try (P_tmpdir, base);
+ base = try_dir (P_tmpdir, base);
#endif
/* Try /var/tmp, /usr/tmp, then /tmp. */
- base = try (vartmp, base);
- base = try (usrtmp, base);
- base = try (tmp, base);
+ base = try_dir (vartmp, base);
+ base = try_dir (usrtmp, base);
+ base = try_dir (tmp, base);
/* If all else fails, use the current directory! */
if (base == 0)
/* Append DIR_SEPARATOR to the directory we've chosen
and return it. */
len = strlen (base);
- tmpdir = xmalloc (len + 2);
+ tmpdir = XNEWVEC (char, len + 2);
strcpy (tmpdir, base);
tmpdir[len] = DIR_SEPARATOR;
tmpdir[len+1] = '\0';
base_len = strlen (base);
suffix_len = strlen (suffix);
- temp_filename = xmalloc (base_len
+ temp_filename = XNEWVEC (char, base_len
+ TEMP_FILE_LEN
+ suffix_len + 1);
strcpy (temp_filename, base);
/*
-@deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len})
+@deftypefn Replacement int mkstemps (char *@var{pattern}, int @var{suffix_len})
-Generate a unique temporary file name from @var{template}.
-@var{template} has the form:
+Generate a unique temporary file name from @var{pattern}.
+@var{pattern} has the form:
@example
@var{path}/ccXXXXXX@var{suffix}
@end example
@var{suffix_len} tells us how long @var{suffix} is (it can be zero
-length). The last six characters of @var{template} before @var{suffix}
+length). The last six characters of @var{pattern} before @var{suffix}
must be @samp{XXXXXX}; they are replaced with a string that makes the
filename unique. Returns a file descriptor open on the file for
reading and writing.
*/
int
-mkstemps (char *template, int suffix_len)
+mkstemps (char *pattern, int suffix_len)
{
static const char letters[]
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
size_t len;
int count;
- len = strlen (template);
+ len = strlen (pattern);
if ((int) len < 6 + suffix_len
- || strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6))
+ || strncmp (&pattern[len - 6 - suffix_len], "XXXXXX", 6))
{
return -1;
}
- XXXXXX = &template[len - 6 - suffix_len];
+ XXXXXX = &pattern[len - 6 - suffix_len];
#ifdef HAVE_GETTIMEOFDAY
/* Get some more or less random data. */
v /= 62;
XXXXXX[5] = letters[v % 62];
- fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
+ fd = open (pattern, O_RDWR|O_CREAT|O_EXCL, 0600);
if (fd >= 0)
/* The file does not exist. */
return fd;
}
/* We return the null string if we can't find a unique file name. */
- template[0] = '\0';
+ pattern[0] = '\0';
return -1;
}
{
struct pex_obj *obj;
- obj = xmalloc (sizeof (*obj));
+ obj = XNEW (struct pex_obj);
obj->flags = flags;
obj->pname = pname;
obj->tempbase = tempbase;
char *add;
++obj->remove_count;
- obj->remove = xrealloc (obj->remove, obj->remove_count * sizeof (char *));
+ obj->remove = XRESIZEVEC (char *, obj->remove, obj->remove_count);
if (allocated)
add = (char *) name;
else
goto error_exit;
++obj->count;
- obj->children = xrealloc (obj->children, obj->count * sizeof (long));
+ obj->children = XRESIZEVEC (long, obj->children, obj->count);
obj->children[obj->count - 1] = pid;
return NULL;
if (obj->number_waited == obj->count)
return 1;
- obj->status = xrealloc (obj->status, obj->count * sizeof (int));
+ obj->status = XRESIZEVEC (int, obj->status, obj->count);
if ((obj->flags & PEX_RECORD_TIMES) != 0)
- obj->time = xrealloc (obj->time, obj->count * sizeof (struct pex_time));
+ obj->time = XRESIZEVEC (struct pex_time, obj->time, obj->count);
ret = 1;
for (i = obj->number_waited; i < obj->count; ++i)
is the number of children which have executed before this
one. */
statuses = (int *) obj->sysdep;
- statuses = xrealloc (statuses, (obj->count + 1) * sizeof (int));
+ statuses = XRESIZEVEC (int, statuses, obj->count + 1);
statuses[obj->count] = status;
obj->sysdep = (void *) statuses;
ret = pex_init_common (flags, pname, tempbase, funcs);
- ret->sysdep = xmalloc (sizeof (struct pex_msdos));
+ ret->sysdep = XNEW (struct pex_msdos);
for (i = 0; i < PEX_MSDOS_FILE_COUNT; ++i)
ret->files[i] = NULL;
ret->statuses = NULL;
outfile = ms->files[outindex];
}
- scmd = xmalloc (strlen (program)
+ scmd = XNEWVEC (char, strlen (program)
+ ((flags & PEXECUTE_SEARCH) != 0 ? 4 : 0)
+ strlen (rf)
+ strlen (infile)
/* Save the exit status for later. When we are called, obj->count
is the number of children which have executed before this
one. */
- ms->statuses = xrealloc (ms->statuses, (obj->count + 1) * sizeof (int));
+ ms->statuses = XRESIZEVEC(int, ms->statuses, obj->count + 1);
ms->statuses[obj->count] = status;
return obj->count;
return cpid;
}
- psl = xmalloc (sizeof (struct status_list));
+ psl = XNEW (struct status_list);
psl->pid = cpid;
psl->status = *status;
if (time != NULL)
for (i = 0; argvec[i] != NULL; i++)
;
- argv = xmalloc ((i + 1) * sizeof (char *));
+ argv = XNEWVEC (char *, i + 1);
for (i = 0; argvec[i] != NULL; i++)
argv[i] = xstrdup (argvec[i]);
argv[i] = NULL;
{
if (temp[j] == '"')
{
- newtemp = xmalloc (len + 2);
+ newtemp = XNEWVEC (char, len + 2);
strncpy (newtemp, temp, j);
newtemp [j] = '\\';
strncpy (&newtemp [j+1], &temp [j], len-j);
len += 2; /* and for the enclosing quotes. */
- temp = xmalloc (len + 1);
+ temp = XNEWVEC (char, len + 1);
temp[0] = '"';
strcpy (temp + 1, argv[i]);
if (trailing_backslash)
{
int *vector;
- vector = xmalloc (idx * sizeof (int));
+ vector = XNEWVEC (int, idx);
if (!pex_get_status (pex, idx, vector))
return -1;
*status = vector[pid];
return -1;
}
- new_environ[size] = malloc (namelen + 1 + vallen);
+ new_environ[size] = (char *) malloc (namelen + 1 + vallen);
if (new_environ[size] == NULL)
{
free ((char *) new_environ);
if (len + 1 < namelen + 1 + vallen)
{
/* The existing string is too short; malloc a new one. */
- char *new = malloc (namelen + 1 + vallen);
- if (new == NULL)
+ char *new_string = (char *) malloc (namelen + 1 + vallen);
+ if (new_string == NULL)
{
UNLOCK;
return -1;
}
- *ep = new;
+ *ep = new_string;
}
memcpy (*ep, name, namelen);
(*ep)[namelen] = '=';
int
sigsetmask (int set)
{
- sigset_t new;
- sigset_t old;
+ sigset_t new_sig;
+ sigset_t old_sig;
- sigemptyset (&new);
+ sigemptyset (&new_sig);
if (set != 0) {
abort(); /* FIXME, we don't know how to translate old mask to new */
}
- sigprocmask(SIG_SETMASK, &new, &old);
+ sigprocmask(SIG_SETMASK, &new_sig, &old_sig);
return 1; /* FIXME, we always return 1 as old value. */
}
#endif
else
k = 10;
- pointers = xmalloc (k * sizeof (void *));
- work = xmalloc (k * sizeof (void *));
+ pointers = XNEWVEC (void*, k);
+ work = XNEWVEC (void*, k);
for (i = 0; i < k; ++i)
{
{
free (buf);
}
- buf = malloc (count + 1);
+ buf = (char *) malloc (count + 1);
if (buf == (char *) 0)
return 0;
for (t = buf + count ; t != buf ; )
if (n < len)
len = n;
- result = malloc (len + 1);
+ result = (char *) malloc (len + 1);
if (!result)
return 0;
result[len] = '\0';
- return memcpy (result, s, len);
+ return (char *) memcpy (result, s, len);
}
for (;;)
{
/* Allocate the memory for the node, and fill it in */
- *pcurr = (ternary_tree) xmalloc (sizeof (ternary_node));
+ *pcurr = XNEW (ternary_node);
curr = *pcurr;
curr->splitchar = *s;
curr->lokid = curr->hikid = curr->eqkid = 0;
#include <unixlib.h>
#else
/* For systems with larger pointers than ints, these must be declared. */
-PTR malloc (size_t);
-PTR realloc (PTR, size_t);
-PTR calloc (size_t, size_t);
-PTR sbrk (ptrdiff_t);
-#endif
+# if HAVE_STDLIB_H && HAVE_UNISTD_H && HAVE_DECL_MALLOC \
+ && HAVE_DECL_REALLOC && HAVE_DECL_CALLOC && HAVE_DECL_SBRK
+# include <stdlib.h>
+# include <unistd.h>
+# else
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
+void *malloc (size_t);
+void *realloc (void *, size_t);
+void *calloc (size_t, size_t);
+void *sbrk (ptrdiff_t);
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
+# endif /* HAVE_STDLIB_H ... */
+#endif /* VMS */
/* The program name if set. */
static const char *name = "";
xstrdup (const char *s)
{
register size_t len = strlen (s) + 1;
- register char *ret = xmalloc (len);
+ register char *ret = XNEWVEC (char, len);
return (char *) memcpy (ret, s, len);
}
#include "libiberty.h"
#ifdef VMS
-#include <errno.h>
-#if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES)
+# include <errno.h>
+# if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES)
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
extern char *strerror (int,...);
-#define DONT_DECLARE_STRERROR
-#endif
-#endif /* VMS */
+# define DONT_DECLARE_STRERROR
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
+# endif
+#endif /* VMS */
+
#ifndef DONT_DECLARE_STRERROR
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
extern char *strerror (int);
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
#endif
/* If strerror returns NULL, we'll format the number into a static buffer. */
if (n < len)
len = n;
- result = xmalloc (len + 1);
+ result = XNEWVEC (char, len + 1);
result[len] = '\0';
- return memcpy (result, s, len);
+ return (char *) memcpy (result, s, len);
}