On old glibc, reallocarray was not introduced, so this case compiles
failed. We should use reallocarray if glibc supports and use
realloc if glibcs doesn't support reallocarray.
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
AC_HAVE_COPY_FILE_RANGE
AC_CHECK_FUNCS([renameat2])
+AC_CHECK_FUNCS([reallocarray])
AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]])
AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[
#include <stddef.h>
if (iter->stack_len >= iter->stack_capacity) {
size_t new_capacity = iter->stack_capacity * 2;
struct btrfs_stack *new_search_stack;
+#ifdef HAVE_REALLOCARRAY
new_search_stack = reallocarray(iter->search_stack, new_capacity,
sizeof(*iter->search_stack));
+#else
+ new_search_stack = realloc(iter->search_stack, new_capacity * sizeof(*iter->search_stack));
+#endif
if (!new_search_stack)
return -ENOMEM;