Modify mallctl output length when needed

This is the only reason why `oldlenp` was designed to be in the form
of a pointer.
This commit is contained in:
Yinan Zhang 2020-07-22 14:20:38 -07:00
parent 4258402047
commit f5fb4e5a97
2 changed files with 3 additions and 1 deletions

View File

@ -3608,7 +3608,8 @@ MAPPED_LIBRARIES:
<constant>NULL</constant>, and <parameter>newlen</parameter> is too
large or too small. Alternatively, <parameter>*oldlenp</parameter>
is too large or too small; in this case as much data as possible
are read despite the error.</para></listitem>
are read despite the error, with the amount of data read being
recorded in <parameter>*oldlenp</parameter>.</para></listitem>
</varlistentry>
<varlistentry>
<term><errorname>ENOENT</errorname></term>

View File

@ -1494,6 +1494,7 @@ ctl_mtx_assert_held(tsdn_t *tsdn) {
size_t copylen = (sizeof(t) <= *oldlenp) \
? sizeof(t) : *oldlenp; \
memcpy(oldp, (void *)&(v), copylen); \
*oldlenp = copylen; \
ret = EINVAL; \
goto label_return; \
} \