1*75f6d617Schristos#serial 5 2*75f6d617Schristos 3*75f6d617Schristosdnl From Jim Meyering. 4*75f6d617Schristosdnl Determine whether realloc works when both arguments are 0. 5*75f6d617Schristosdnl If it doesn't, arrange to use the replacement function. 6*75f6d617Schristosdnl 7*75f6d617Schristos 8*75f6d617SchristosAC_DEFUN([jm_FUNC_REALLOC], 9*75f6d617Schristos[ 10*75f6d617Schristos dnl xmalloc.c requires that this symbol be defined so it doesn't 11*75f6d617Schristos dnl mistakenly use a broken realloc -- as it might if this test were omitted. 12*75f6d617Schristos AC_DEFINE(HAVE_DONE_WORKING_REALLOC_CHECK, 1, 13*75f6d617Schristos [Define if the realloc check has been performed. ]) 14*75f6d617Schristos 15*75f6d617Schristos AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc, 16*75f6d617Schristos [AC_TRY_RUN([ 17*75f6d617Schristos char *realloc (); 18*75f6d617Schristos int 19*75f6d617Schristos main () 20*75f6d617Schristos { 21*75f6d617Schristos exit (realloc (0, 0) ? 0 : 1); 22*75f6d617Schristos } 23*75f6d617Schristos ], 24*75f6d617Schristos jm_cv_func_working_realloc=yes, 25*75f6d617Schristos jm_cv_func_working_realloc=no, 26*75f6d617Schristos dnl When crosscompiling, assume realloc is broken. 27*75f6d617Schristos jm_cv_func_working_realloc=no) 28*75f6d617Schristos ]) 29*75f6d617Schristos if test $jm_cv_func_working_realloc = no; then 30*75f6d617Schristos AC_LIBOBJ(realloc) 31*75f6d617Schristos AC_DEFINE(realloc, rpl_realloc, 32*75f6d617Schristos [Define to rpl_realloc if the replacement function should be used.]) 33*75f6d617Schristos fi 34*75f6d617Schristos]) 35