fix: mallctl("version", ...) crashes on macOS

This commit is contained in:
Marcus Holland-Moritz 2024-04-14 16:16:52 +02:00
parent dadc2e0254
commit 5d4017de4f

View File

@ -53,9 +53,13 @@ std::string version_to_string(uint64_t version, version_format fmt) {
#ifdef DWARFS_USE_JEMALLOC
std::string get_jemalloc_version() {
const char* j;
char const* j;
#ifdef __APPLE__
j = JEMALLOC_VERSION;
#else
size_t s = sizeof(j);
::mallctl("version", &j, &s, nullptr, 0);
#endif
std::string rv{j};
if (auto pos = rv.find('-'); pos != std::string::npos) {
rv.erase(pos, std::string::npos);