4 dnl Determine whether malloc accepts 0 as its argument.
5 dnl If it doesn't, arrange to use the replacement function.
7 dnl If you use this macro in a package, you should
8 dnl add the following two lines to acconfig.h:
9 dnl /* Define to rpl_malloc if the replacement function should be used. */
13 AC_DEFUN(jm_FUNC_MALLOC,
16 dnl This code is deliberately never run via ./configure.
17 dnl FIXME: this is a gross hack to make autoheader put an entry
18 dnl for this symbol in config.h.in.
19 AC_CHECK_FUNCS(DONE_WORKING_MALLOC_CHECK)
21 dnl xmalloc.c requires that this symbol be defined so it doesn't
22 dnl mistakenly use a broken malloc -- as it might if this test were omitted.
23 ac_kludge=HAVE_DONE_WORKING_MALLOC_CHECK
24 AC_DEFINE_UNQUOTED($ac_kludge)
26 AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
32 exit (malloc (0) ? 0 : 1);
35 jm_cv_func_working_malloc=yes,
36 jm_cv_func_working_malloc=no,
37 dnl When crosscompiling, assume malloc is broken.
38 jm_cv_func_working_malloc=no)
40 if test $jm_cv_func_working_malloc = no; then
41 LIBOBJS="$LIBOBJS malloc.o"
42 AC_DEFINE_UNQUOTED(malloc, rpl_malloc)