From: Alex Rousskov Date: Wed, 30 Mar 2016 16:15:28 +0000 (+1300) Subject: Simplify MemPools::GetInstance() X-Git-Tag: SQUID_4_0_8~7^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=399eb81bcccef2f7aeaa7594188280a4e6c56d79;p=thirdparty%2Fsquid.git Simplify MemPools::GetInstance() --- diff --git a/src/mem/Pool.cc b/src/mem/Pool.cc index 42e2e9b1b5..ff7c4e9a7a 100644 --- a/src/mem/Pool.cc +++ b/src/mem/Pool.cc @@ -29,13 +29,10 @@ static int Pool_id_counter = 0; MemPools & MemPools::GetInstance() { - /* Must use this idiom, as we can be double-initialised - * if we are called during static initialisations. - */ - static MemPools *Instance = nullptr; - if (!Instance) { - Instance = new MemPools; - } + // We must initialize on first use (which may happen during static + // initialization) and preserve until the last user is gone (which + // may happen long after main() exit). We currently preserve forever. + static MemPools *Instance = new MemPools; return *Instance; }