Move use_pool() to mempool.c and rename to mempool_enabled()

The only user is in hashmap.c, but it's a mempool thing.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-10-11 10:55:41 +02:00
parent 6939fb9eb4
commit 7c48ea0280
3 changed files with 17 additions and 16 deletions
+14 -2
View File
@@ -3,8 +3,10 @@
#include <stdint.h>
#include <stdlib.h>
#include "env-util.h"
#include "macro.h"
#include "mempool.h"
#include "process-util.h"
#include "util.h"
struct pool {
@@ -70,8 +72,19 @@ void mempool_free_tile(struct mempool *mp, void *p) {
mp->freelist = p;
}
#if VALGRIND
bool mempool_enabled(void) {
static int b = -1;
if (!is_main_thread())
return false;
if (b < 0)
b = getenv_bool("SYSTEMD_MEMPOOL") != 0;
return b;
}
#if VALGRIND
void mempool_drop(struct mempool *mp) {
struct pool *p = mp->first_pool;
while (p) {
@@ -81,5 +94,4 @@ void mempool_drop(struct mempool *mp) {
p = n;
}
}
#endif