s4:heimdal: import lorikeet-heimdal-202201172009 (commit 5a0b45cd723628b3690ea848548b...
[samba.git] / source4 / heimdal / cf / broken-realloc.m4
diff --git a/source4/heimdal/cf/broken-realloc.m4 b/source4/heimdal/cf/broken-realloc.m4
new file mode 100644 (file)
index 0000000..b6d962a
--- /dev/null
@@ -0,0 +1,25 @@
+dnl
+dnl $Id$
+dnl
+dnl Test for realloc that doesn't handle NULL as first parameter
+dnl
+AC_DEFUN([rk_BROKEN_REALLOC], [
+AC_CACHE_CHECK(if realloc if broken, ac_cv_func_realloc_broken, [
+ac_cv_func_realloc_broken=no
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stddef.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv)
+{
+       return realloc(NULL, 17) == NULL;
+}
+]])],[:], [ac_cv_func_realloc_broken=yes],[:])
+])
+if test "$ac_cv_func_realloc_broken" = yes ; then
+       AC_DEFINE(BROKEN_REALLOC, 1, [Define if realloc(NULL) doesn't work.])
+fi
+AH_BOTTOM([#ifdef BROKEN_REALLOC
+#define realloc(X, Y) rk_realloc((X), (Y))
+#endif])
+])