libiberty.h (ACONCAT): Properly cast value of alloca().

include/
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.

libiberty/
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().

From-SVN: r100115
This commit is contained in:
Gabriel Dos Reis 2005-05-24 20:48:25 +00:00 committed by Gabriel Dos Reis
parent de3e06c62c
commit d7cf8390c7
38 changed files with 651 additions and 155 deletions

View File

@ -1,3 +1,10 @@
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.

View File

@ -258,11 +258,11 @@ So instead we use the macro below and test it against specific values. */
/* 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

View File

@ -156,7 +156,7 @@ extern char *libiberty_concat_ptr;
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. */

View File

@ -1,3 +1,79 @@
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

View File

@ -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. */
@ -191,20 +197,20 @@ C_alloca (size_t 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));
}
}

View File

@ -61,7 +61,7 @@ choose_temp_base (void)
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);

View File

@ -127,7 +127,13 @@ concat_copy (char *dst, const char *first, ...)
return save_dst;
}
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
char *libiberty_concat_ptr;
#ifdef __cplusplus
}
#endif /* __cplusplus */
/* @undocumented concat_copy2 */
@ -150,7 +156,7 @@ concat (const char *first, ...)
/* 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. */
@ -188,7 +194,7 @@ reconcat (char *optr, const char *first, ...)
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. */

View File

@ -45,9 +45,29 @@
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

352
libiberty/configure vendored
View File

@ -7214,6 +7214,358 @@ else
_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

View File

@ -519,6 +519,7 @@ if test -z "${setobjs}"; then
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

View File

@ -210,7 +210,7 @@ struct d_print_template
/* 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. */
@ -2551,7 +2551,7 @@ d_print_resize (struct d_print_info *dpi, size_t add)
char *newbuf;
newalc = dpi->alc * 2;
newbuf = realloc (dpi->buf, newalc);
newbuf = (char *) realloc (dpi->buf, newalc);
if (newbuf == NULL)
{
free (dpi->buf);
@ -2629,7 +2629,7 @@ cplus_demangle_print (int options, const struct demangle_component *dc,
dpi.options = options;
dpi.alc = estimate + 1;
dpi.buf = malloc (dpi.alc);
dpi.buf = (char *) malloc (dpi.alc);
if (dpi.buf == NULL)
{
*palc = 1;
@ -2730,7 +2730,7 @@ d_print_comp (struct d_print_info *dpi,
{
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
@ -2826,7 +2826,7 @@ d_print_comp (struct d_print_info *dpi,
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))
{
@ -3683,7 +3683,7 @@ d_print_cast (struct d_print_info *dpi,
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)));
@ -3764,7 +3764,7 @@ d_demangle (const char* mangled, int options, size_t *palc)
{
char *r;
r = malloc (40 + len - 11);
r = (char *) malloc (40 + len - 11);
if (r == NULL)
*palc = 1;
else

View File

@ -130,18 +130,18 @@ cplus_demangle_fill_component (struct demangle_component *p,
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];

View File

@ -892,7 +892,7 @@ grow_vect (char **old_vect, size_t *size, size_t min_size, int element_size)
*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);
}
}
@ -1102,56 +1102,52 @@ work_stuff_copy_to_from (struct work_stuff *to, struct work_stuff *from)
/* 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);
}
@ -1895,7 +1891,7 @@ demangle_template_value_parm (struct work_stuff *work, const char **mangled,
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
@ -2001,7 +1997,7 @@ demangle_template (struct work_stuff *work, const char **mangled,
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;
@ -2026,7 +2022,7 @@ demangle_template (struct work_stuff *work, const char **mangled,
{
/* 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';
}
@ -2054,7 +2050,7 @@ demangle_template (struct work_stuff *work, const char **mangled,
{
/* 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';
}
@ -2100,7 +2096,7 @@ demangle_template (struct work_stuff *work, const char **mangled,
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';
@ -2998,7 +2994,7 @@ recursively_demangle(struct work_stuff *work, const char **mangled,
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';
@ -3969,7 +3965,7 @@ do_hpacc_template_literal (struct work_stuff *work, const char **mangled,
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';
@ -4071,7 +4067,7 @@ do_arg (struct work_stuff *work, const char **mangled, string *result)
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;
@ -4095,18 +4091,16 @@ remember_type (struct work_stuff *work, const char *start, int len)
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;
@ -4124,18 +4118,16 @@ remember_Ktype (struct work_stuff *work, const char *start, int len)
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;
@ -4155,15 +4147,13 @@ register_Btype (struct work_stuff *work)
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++;
@ -4179,7 +4169,7 @@ remember_Btype (struct work_stuff *work, const char *start,
{
char *tem;
tem = xmalloc (len + 1);
tem = XNEWVEC (char, len + 1);
memcpy (tem, start, len);
tem[len] = '\0';
work -> btypevec[index] = tem;
@ -4600,7 +4590,7 @@ string_need (string *s, int n)
{
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)
@ -4608,7 +4598,7 @@ string_need (string *s, int 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;
}

View File

@ -67,7 +67,7 @@ dyn_string_init (struct dyn_string *ds_struct_ptr, int space)
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;
@ -96,7 +96,7 @@ dyn_string_new (int space)
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;
@ -159,7 +159,7 @@ dyn_string_resize (dyn_string_t ds, int space)
return NULL;
}
#else
ds->s = (char *) xrealloc (ds->s, ds->allocated);
ds->s = XRESIZEVEC (char, ds->s, ds->allocated);
#endif
}

View File

@ -124,7 +124,7 @@ fnmatch (const char *pattern, const char *string, int flags)
case '[':
{
/* Nonzero if the sense of the character class is inverted. */
register int not;
register int negate;
if (*n == '\0')
return FNM_NOMATCH;
@ -133,8 +133,8 @@ fnmatch (const char *pattern, const char *string, int flags)
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
not = (*p == '!' || *p == '^');
if (not)
negate = (*p == '!' || *p == '^');
if (negate)
++p;
c = *p++;
@ -177,7 +177,7 @@ fnmatch (const char *pattern, const char *string, int flags)
if (c == ']')
break;
}
if (!not)
if (!negate)
return FNM_NOMATCH;
break;
@ -194,7 +194,7 @@ fnmatch (const char *pattern, const char *string, int flags)
/* XXX 1003.2d11 is unclear if this is right. */
++p;
}
if (not)
if (negate)
return FNM_NOMATCH;
}
break;

View File

@ -212,8 +212,16 @@ static char *posixly_correct;
/* 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 *
@ -325,7 +333,7 @@ exchange (char **argv)
{
/* 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

View File

@ -84,7 +84,7 @@ getpwd (void)
&& 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);
@ -117,7 +117,7 @@ getpwd (void)
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

View File

@ -216,20 +216,30 @@ eq_pointer (const PTR p1, const PTR p2)
return p1 == p2;
}
/* 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. */
inline size_t
htab_size (htab_t htab)
#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. */
@ -317,15 +327,10 @@ htab_create_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
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;

View File

@ -117,7 +117,7 @@ lrealpath (const char *filename)
{
/* 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);

View File

@ -102,7 +102,7 @@ static void free_split_directories (char **);
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;

View File

@ -61,10 +61,10 @@ extern int mkstemps (char *, int);
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;
@ -103,18 +103,18 @@ choose_tmpdir (void)
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)
@ -123,7 +123,7 @@ choose_tmpdir (void)
/* 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';
@ -158,7 +158,7 @@ make_temp_file (const char *suffix)
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);

View File

@ -51,17 +51,17 @@ typedef unsigned long gcc_uint64_t;
/*
@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.
@ -71,7 +71,7 @@ reading and writing.
*/
int
mkstemps (char *template, int suffix_len)
mkstemps (char *pattern, int suffix_len)
{
static const char letters[]
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@ -83,15 +83,15 @@ mkstemps (char *template, int suffix_len)
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. */
@ -119,7 +119,7 @@ mkstemps (char *template, int suffix_len)
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;
@ -131,6 +131,6 @@ mkstemps (char *template, int suffix_len)
}
/* We return the null string if we can't find a unique file name. */
template[0] = '\0';
pattern[0] = '\0';
return -1;
}

View File

@ -55,7 +55,7 @@ pex_init_common (int flags, const char *pname, const char *tempbase,
{
struct pex_obj *obj;
obj = xmalloc (sizeof (*obj));
obj = XNEW (struct pex_obj);
obj->flags = flags;
obj->pname = pname;
obj->tempbase = tempbase;
@ -83,7 +83,7 @@ pex_add_remove (struct pex_obj *obj, const char *name, int allocated)
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
@ -280,7 +280,7 @@ pex_run (struct pex_obj *obj, int flags, const char *executable,
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;
@ -352,9 +352,9 @@ pex_get_status_and_time (struct pex_obj *obj, int done, const char **errmsg,
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)

View File

@ -257,7 +257,7 @@ pex_djgpp_exec_child (struct pex_obj *obj, int flags, const char *executable,
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;

View File

@ -89,7 +89,7 @@ pex_init (int flags, const char *pname, const char *tempbase)
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;
@ -210,7 +210,7 @@ pex_msdos_exec_child (struct pex_obj *obj, int flags, const char *executable,
outfile = ms->files[outindex];
}
scmd = xmalloc (strlen (program)
scmd = XNEWVEC (char, strlen (program)
+ ((flags & PEXECUTE_SEARCH) != 0 ? 4 : 0)
+ strlen (rf)
+ strlen (infile)
@ -269,7 +269,7 @@ pex_msdos_exec_child (struct pex_obj *obj, int flags, const char *executable,
/* 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;

View File

@ -252,7 +252,7 @@ pex_wait (struct pex_obj *obj, pid_t pid, int *status, struct pex_time *time)
return cpid;
}
psl = xmalloc (sizeof (struct status_list));
psl = XNEW (struct status_list);
psl->pid = cpid;
psl->status = *status;
if (time != NULL)

View File

@ -79,7 +79,7 @@ fix_argv (char * const *argvec)
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;
@ -105,7 +105,7 @@ fix_argv (char * const *argvec)
{
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);
@ -150,7 +150,7 @@ fix_argv (char * const *argvec)
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)

View File

@ -99,7 +99,7 @@ pwait (int pid, int *status, int flags ATTRIBUTE_UNUSED)
{
int *vector;
vector = xmalloc (idx * sizeof (int));
vector = XNEWVEC (int, idx);
if (!pex_get_status (pex, idx, vector))
return -1;
*status = vector[pid];

View File

@ -115,7 +115,7 @@ setenv (const char *name, const char *value, int replace)
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);
@ -142,13 +142,13 @@ setenv (const char *name, const char *value, int replace)
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] = '=';

View File

@ -27,14 +27,14 @@ extern void abort (void) ATTRIBUTE_NORETURN;
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

View File

@ -155,8 +155,8 @@ int main (int argc, char **argv)
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)
{

View File

@ -57,7 +57,7 @@ spaces (int count)
{
free (buf);
}
buf = malloc (count + 1);
buf = (char *) malloc (count + 1);
if (buf == (char *) 0)
return 0;
for (t = buf + count ; t != buf ; )

View File

@ -46,10 +46,10 @@ strndup (const char *s, size_t n)
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);
}

View File

@ -74,7 +74,7 @@ ternary_insert (ternary_tree *root, const char *s, PTR data, int replace)
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;

View File

@ -75,11 +75,23 @@ function will be called to print an error message and terminate execution.
#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 = "";

View File

@ -31,6 +31,6 @@ char *
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);
}

View File

@ -21,13 +21,26 @@ will never return a @code{NULL} pointer.
#ifdef VMS
# 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
# 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. */

View File

@ -53,8 +53,8 @@ xstrndup (const char *s, size_t n)
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);
}