| 189 | |
| 190 | template<typename T> |
| 191 | Try<T> readJemallocSetting(const char* name) |
| 192 | { |
| 193 | #ifdef LIBPROCESS_ALLOW_JEMALLOC |
| 194 | if (!detectJemalloc()) { |
| 195 | return Error(JEMALLOC_NOT_DETECTED_MESSAGE); |
| 196 | } |
| 197 | |
| 198 | T value; |
| 199 | size_t size = sizeof(value); |
| 200 | int error = ::mallctl(name, &value, &size, nullptr, 0); |
| 201 | |
| 202 | if (error) { |
| 203 | return Error(strings::format( |
| 204 | "Couldn't read option %s: %s", name, ::strerror(error)).get()); |
| 205 | } |
| 206 | |
| 207 | return value; |
| 208 | #else |
| 209 | UNREACHABLE(); |
| 210 | #endif |
| 211 | } |
| 212 | |
| 213 | |
| 214 | // Returns an error on failure or the previous value on success. |
nothing calls this directly
no test coverage detected