Make the default option of zero realloc match the system allocator.
This commit is contained in:
parent
66c889500a
commit
8cb814629a
@ -638,6 +638,7 @@ dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
|
|||||||
dnl definitions need to be seen before any headers are included, which is a pain
|
dnl definitions need to be seen before any headers are included, which is a pain
|
||||||
dnl to make happen otherwise.
|
dnl to make happen otherwise.
|
||||||
default_retain="0"
|
default_retain="0"
|
||||||
|
zero_realloc_default_free="0"
|
||||||
maps_coalesce="1"
|
maps_coalesce="1"
|
||||||
DUMP_SYMS="${NM} -a"
|
DUMP_SYMS="${NM} -a"
|
||||||
SYM_PREFIX=""
|
SYM_PREFIX=""
|
||||||
@ -684,6 +685,7 @@ case "${host}" in
|
|||||||
if test "${LG_SIZEOF_PTR}" = "3"; then
|
if test "${LG_SIZEOF_PTR}" = "3"; then
|
||||||
default_retain="1"
|
default_retain="1"
|
||||||
fi
|
fi
|
||||||
|
zero_realloc_default_free="1"
|
||||||
;;
|
;;
|
||||||
*-*-linux*)
|
*-*-linux*)
|
||||||
dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE.
|
dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE.
|
||||||
@ -698,6 +700,7 @@ case "${host}" in
|
|||||||
if test "${LG_SIZEOF_PTR}" = "3"; then
|
if test "${LG_SIZEOF_PTR}" = "3"; then
|
||||||
default_retain="1"
|
default_retain="1"
|
||||||
fi
|
fi
|
||||||
|
zero_realloc_default_free="1"
|
||||||
;;
|
;;
|
||||||
*-*-kfreebsd*)
|
*-*-kfreebsd*)
|
||||||
dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE.
|
dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE.
|
||||||
@ -773,6 +776,7 @@ case "${host}" in
|
|||||||
if test "${LG_SIZEOF_PTR}" = "3"; then
|
if test "${LG_SIZEOF_PTR}" = "3"; then
|
||||||
default_retain="1"
|
default_retain="1"
|
||||||
fi
|
fi
|
||||||
|
zero_realloc_default_free="1"
|
||||||
;;
|
;;
|
||||||
*-*-nto-qnx)
|
*-*-nto-qnx)
|
||||||
abi="elf"
|
abi="elf"
|
||||||
@ -1395,6 +1399,11 @@ if test "x$default_retain" = "x1" ; then
|
|||||||
AC_DEFINE([JEMALLOC_RETAIN], [ ], [ ])
|
AC_DEFINE([JEMALLOC_RETAIN], [ ], [ ])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl Indicate whether realloc(ptr, 0) defaults to the "alloc" behavior.
|
||||||
|
if test "x$zero_realloc_default_free" = "x1" ; then
|
||||||
|
AC_DEFINE([JEMALLOC_ZERO_REALLOC_DEFAULT_FREE], [ ], [ ])
|
||||||
|
fi
|
||||||
|
|
||||||
dnl Enable allocation from DSS if supported by the OS.
|
dnl Enable allocation from DSS if supported by the OS.
|
||||||
have_dss="1"
|
have_dss="1"
|
||||||
dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
|
dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
|
||||||
|
@ -1578,13 +1578,14 @@ malloc_conf = "xmalloc:true";]]></programlisting>
|
|||||||
<literal>r-</literal>
|
<literal>r-</literal>
|
||||||
</term>
|
</term>
|
||||||
<listitem><para> Determines the behavior of
|
<listitem><para> Determines the behavior of
|
||||||
<function>realloc()</function> when passed a value of zero for the new
|
<function>realloc()</function> when passed a value of zero for the new
|
||||||
size. <quote>alloc</quote> treats this as an allocation of size zero
|
size. <quote>alloc</quote> treats this as an allocation of size zero
|
||||||
(and returns a non-null result except in case of resource exhaustion).
|
(and returns a non-null result except in case of resource exhaustion).
|
||||||
<quote>free</quote> treats this as a deallocation of the pointer, and
|
<quote>free</quote> treats this as a deallocation of the pointer, and
|
||||||
returns <constant>NULL</constant> without setting
|
returns <constant>NULL</constant> without setting
|
||||||
<varname>errno</varname>. <quote>abort</quote> aborts the process if
|
<varname>errno</varname>. <quote>abort</quote> aborts the process if
|
||||||
zero is passed. The default is <quote>alloc</quote>.</para>
|
zero is passed. The default is <quote>free</quote> on Linux and
|
||||||
|
Windows, and <quote>alloc</quote> elsewhere.</para>
|
||||||
|
|
||||||
<para>There is considerable divergence of behaviors across
|
<para>There is considerable divergence of behaviors across
|
||||||
implementations in handling this case. Many have the behavior of
|
implementations in handling this case. Many have the behavior of
|
||||||
|
@ -421,4 +421,7 @@
|
|||||||
/* Darwin VM_MAKE_TAG support */
|
/* Darwin VM_MAKE_TAG support */
|
||||||
#undef JEMALLOC_HAVE_VM_MAKE_TAG
|
#undef JEMALLOC_HAVE_VM_MAKE_TAG
|
||||||
|
|
||||||
|
/* If defined, realloc(ptr, 0) defaults to "free" instead of "alloc". */
|
||||||
|
#undef JEMALLOC_ZERO_REALLOC_DEFAULT_FREE
|
||||||
|
|
||||||
#endif /* JEMALLOC_INTERNAL_DEFS_H_ */
|
#endif /* JEMALLOC_INTERNAL_DEFS_H_ */
|
||||||
|
@ -112,7 +112,12 @@ bool opt_cache_oblivious =
|
|||||||
;
|
;
|
||||||
|
|
||||||
zero_realloc_action_t opt_zero_realloc_action =
|
zero_realloc_action_t opt_zero_realloc_action =
|
||||||
zero_realloc_action_alloc;
|
#ifdef JEMALLOC_ZERO_REALLOC_DEFAULT_FREE
|
||||||
|
zero_realloc_action_free
|
||||||
|
#else
|
||||||
|
zero_realloc_action_alloc
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
atomic_zu_t zero_realloc_count = ATOMIC_INIT(0);
|
atomic_zu_t zero_realloc_count = ATOMIC_INIT(0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user