Make the default option of zero realloc match the system allocator.

This commit is contained in:
Qi Wang
2022-05-03 15:41:43 -07:00
committed by Qi Wang
parent 66c889500a
commit 8cb814629a
4 changed files with 26 additions and 8 deletions

View File

@@ -1578,13 +1578,14 @@ malloc_conf = "xmalloc:true";]]></programlisting>
<literal>r-</literal>
</term>
<listitem><para> Determines the behavior of
<function>realloc()</function> when passed a value of zero for the new
size. <quote>alloc</quote> treats this as an allocation of size zero
(and returns a non-null result except in case of resource exhaustion).
<quote>free</quote> treats this as a deallocation of the pointer, and
returns <constant>NULL</constant> without setting
<varname>errno</varname>. <quote>abort</quote> aborts the process if
zero is passed. The default is <quote>alloc</quote>.</para>
<function>realloc()</function> when passed a value of zero for the new
size. <quote>alloc</quote> treats this as an allocation of size zero
(and returns a non-null result except in case of resource exhaustion).
<quote>free</quote> treats this as a deallocation of the pointer, and
returns <constant>NULL</constant> without setting
<varname>errno</varname>. <quote>abort</quote> aborts the process if
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
implementations in handling this case. Many have the behavior of