0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-19 19:33:45 +02:00

ircd::allocator::je: Minor cleanup; consistent defs; simplify casts; remove tiny tls.

This commit is contained in:
Jason Volk 2022-05-28 00:11:51 -07:00
parent 48486c2e27
commit 68db7cf9e2

View file

@ -16,9 +16,11 @@
namespace ircd::allocator::je namespace ircd::allocator::je
{ {
static std::function<void (std::ostream &, const string_view &)> stats_callback; using callback_prototype = void (std::ostream &, const string_view &);
static void stats_handler(void *, const char *) noexcept; static void stats_handler(void *, const char *) noexcept;
static std::function<callback_prototype> stats_callback;
extern info::versions malloc_version_api; extern info::versions malloc_version_api;
extern info::versions malloc_version_abi; extern info::versions malloc_version_abi;
} }
@ -57,7 +59,10 @@ ircd::allocator::je::malloc_version_abi
#ifdef IRCD_ALLOCATOR_JEMALLOC #ifdef IRCD_ALLOCATOR_JEMALLOC
const string_view val const string_view val
{ {
*reinterpret_cast<const char *const *>(data(allocator::get("version", buf))) *reinterpret_cast<const char *const *>
(
data(allocator::get("version", buf))
)
}; };
if(!val) if(!val)
@ -94,7 +99,7 @@ ircd::string_view
ircd::allocator::get(const string_view &key_, ircd::allocator::get(const string_view &key_,
const mutable_buffer &buf) const mutable_buffer &buf)
{ {
thread_local char key[128]; char key[128];
strlcpy(key, key_); strlcpy(key, key_);
size_t len(size(buf)); size_t len(size(buf));
@ -112,11 +117,11 @@ ircd::allocator::set(const string_view &key_,
const string_view &val, const string_view &val,
const mutable_buffer &cur) const mutable_buffer &cur)
{ {
thread_local char key[128]; char key[128];
strlcpy(key, key_); strlcpy(key, key_);
size_t curlen(size(cur)); size_t curlen(size(cur));
syscall(::mallctl, key, data(cur), &curlen, const_cast<char *>(data(val)), size(val)); syscall(::mallctl, key, data(cur), &curlen, mutable_cast(data(val)), size(val));
return string_view return string_view
{ {
data(cur), std::min(curlen, size(cur)) data(cur), std::min(curlen, size(cur))
@ -156,7 +161,7 @@ ircd::allocator::info(const mutable_buffer &buf,
out << msg; out << msg;
}; };
thread_local char opts_buf[64]; char opts_buf[64];
const char *const opts const char *const opts
{ {
opts_? opts_?