From f5fb4e5a970077e308d7e4e3f1cbbec4cf76a8d9 Mon Sep 17 00:00:00 2001 From: Yinan Zhang Date: Wed, 22 Jul 2020 14:20:38 -0700 Subject: [PATCH] Modify mallctl output length when needed This is the only reason why `oldlenp` was designed to be in the form of a pointer. --- doc/jemalloc.xml.in | 3 ++- src/ctl.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/jemalloc.xml.in b/doc/jemalloc.xml.in index 5472294c..19afe362 100644 --- a/doc/jemalloc.xml.in +++ b/doc/jemalloc.xml.in @@ -3608,7 +3608,8 @@ MAPPED_LIBRARIES: NULL, and newlen is too large or too small. Alternatively, *oldlenp is too large or too small; in this case as much data as possible - are read despite the error. + are read despite the error, with the amount of data read being + recorded in *oldlenp. ENOENT diff --git a/src/ctl.c b/src/ctl.c index 62a82a20..92e9f511 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -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; \ } \