Turn mempool_enabled() into a weak symbol
Before we had the following scheme: mempool_enabled() would check mempool_use_allowed, and libsystemd-shared would be linked with a .c file that provides mempool_use_allowed=true, while other things would linked with a different .c file with mempool_use_allowed=false. In the new scheme, mempool_enabled() itself is a weak symbol. If it's not found, we assume false. So it only needs to be provided for libsystemd-shared, where it can return false or true. test-set-disable-mempool is libshared, so it gets the symbol. But then we actually disable the mempool via envvar. mempool_enable() is called to check its return value directly.
This commit is contained in:
+3
-4
@@ -771,16 +771,15 @@ static void shared_hash_key_initialize(void) {
|
||||
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 = mempool_enabled();
|
||||
bool use_pool = mempool_enabled && mempool_enabled();
|
||||
|
||||
h = up ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
|
||||
h = use_pool ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
h->type = type;
|
||||
h->from_pool = up;
|
||||
h->from_pool = use_pool;
|
||||
h->hash_ops = hash_ops ?: &trivial_hash_ops;
|
||||
|
||||
if (type == HASHMAP_TYPE_ORDERED) {
|
||||
|
||||
Reference in New Issue
Block a user