mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 13:04:15 -04:00
refactor: make sure jemalloc version in always initialized
This commit is contained in:
parent
bdb5469b7b
commit
807dbb9aef
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
@ -56,13 +57,14 @@ std::string version_to_string(uint64_t version, version_format fmt) {
|
|||||||
|
|
||||||
#ifdef DWARFS_USE_JEMALLOC
|
#ifdef DWARFS_USE_JEMALLOC
|
||||||
std::string get_jemalloc_version() {
|
std::string get_jemalloc_version() {
|
||||||
char const* j;
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
j = JEMALLOC_VERSION;
|
char const* j = JEMALLOC_VERSION;
|
||||||
#else
|
#else
|
||||||
|
char const* j = nullptr;
|
||||||
size_t s = sizeof(j);
|
size_t s = sizeof(j);
|
||||||
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
|
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
|
||||||
::mallctl("version", &j, &s, nullptr, 0);
|
::mallctl("version", &j, &s, nullptr, 0);
|
||||||
|
assert(j);
|
||||||
#endif
|
#endif
|
||||||
std::string rv{j};
|
std::string rv{j};
|
||||||
if (auto pos = rv.find('-'); pos != std::string::npos) {
|
if (auto pos = rv.find('-'); pos != std::string::npos) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user