Skip to content

Commit

Permalink
[Minor] Sanity check as ctors order is not defined
Browse files Browse the repository at this point in the history
Issue: #3721
  • Loading branch information
vstakhov committed Apr 16, 2021
1 parent f09b8e5 commit cf6947e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/libutil/mem_pool.c
Expand Up @@ -129,7 +129,9 @@ rspamd_mempool_entry_new (const gchar *loc)

RSPAMD_CONSTRUCTOR (rspamd_mempool_entries_ctor)
{
mempool_entries = kh_init (mempool_entry);
if (mempool_entries == NULL) {
mempool_entries = kh_init (mempool_entry);
}
}

RSPAMD_DESTRUCTOR (rspamd_mempool_entries_dtor)
Expand All @@ -150,6 +152,10 @@ rspamd_mempool_get_entry (const gchar *loc)
khiter_t k;
struct rspamd_mempool_entry_point *elt;

if (G_UNLIKELY (!mempool_entries)) {
rspamd_mempool_entries_ctor();
}

k = kh_get (mempool_entry, mempool_entries, loc);

if (k != kh_end (mempool_entries)) {
Expand All @@ -158,10 +164,9 @@ rspamd_mempool_get_entry (const gchar *loc)
return elt;
}

return rspamd_mempool_entry_new (loc);
return rspamd_mempool_entry_new(loc);
}


static struct _pool_chain *
rspamd_mempool_chain_new (gsize size, enum rspamd_mempool_chain_type pool_type)
{
Expand Down

0 comments on commit cf6947e

Please sign in to comment.