]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Move use_pool() to mempool.c and rename to mempool_enabled()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 9 Oct 2018 13:53:35 +0000 (15:53 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 11 Oct 2018 08:55:41 +0000 (10:55 +0200)
The only user is in hashmap.c, but it's a mempool thing.

src/basic/hashmap.c
src/basic/mempool.c
src/basic/mempool.h

index 44d718c83d223b1c5abb11ed295e2ef967f3034f..018ef5e7d809dd278284178974e07b477e6a47ef 100644 (file)
@@ -6,7 +6,6 @@
 #include <string.h>
 
 #include "alloc-util.h"
-#include "env-util.h"
 #include "fileio.h"
 #include "hashmap.h"
 #include "macro.h"
@@ -767,24 +766,12 @@ static void reset_direct_storage(HashmapBase *h) {
         memset(p, DIB_RAW_INIT, sizeof(dib_raw_t) * hi->n_direct_buckets);
 }
 
-static bool use_pool(void) {
-        static int b = -1;
-
-        if (!is_main_thread())
-                return false;
-
-        if (b < 0)
-                b = getenv_bool("SYSTEMD_MEMPOOL") != 0;
-
-        return b;
-}
-
 static struct HashmapBase *hashmap_base_new(const struct hash_ops *hash_ops, enum HashmapType type HASHMAP_DEBUG_PARAMS) {
         HashmapBase *h;
         const struct hashmap_type_info *hi = &hashmap_type_info[type];
         bool up;
 
-        up = use_pool();
+        up = mempool_enabled();
 
         h = up ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
         if (!h)
index a5ec8a1020362c8dea7af0265f2bac17057740f7..9f17b77e472df3ac1cb8e555cf5f86c10b271b07 100644 (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
index 4098535c6f39d3115e8c7733b6d1ad9b616ddcd1..d3ad63628f9d04da635c8895cac6df9643a4008b 100644 (file)
@@ -22,6 +22,8 @@ static struct mempool pool_name = { \
         .at_least = alloc_at_least, \
 }
 
+bool mempool_enabled(void);
+
 #if VALGRIND
 void mempool_drop(struct mempool *mp);
 #endif