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:
+14
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user