From: Amos Jeffries Date: Thu, 24 Mar 2016 10:12:23 +0000 (+1300) Subject: Reduce scope of MemIsInitialized X-Git-Tag: SQUID_4_0_8~20^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=51494bc69e7de18f3c1949593c8cbbc1c6f8b100;p=thirdparty%2Fsquid.git Reduce scope of MemIsInitialized --- diff --git a/src/mem/old_api.cc b/src/mem/old_api.cc index b9d28b5db8..3ef4419885 100644 --- a/src/mem/old_api.cc +++ b/src/mem/old_api.cc @@ -46,9 +46,6 @@ static void memStringStats(std::ostream &); static double xm_time = 0; static double xm_deltat = 0; -/* all pools are ready to be used */ -static bool MemIsInitialized = false; - /* string pools */ #define mem_str_pool_count 6 @@ -246,7 +243,6 @@ memAllocString(size_t net_size, size_t * gross_size) *gross_size = pool ? pool->objectSize() : net_size; assert(*gross_size >= net_size); - // may forget [de]allocations until MemIsInitialized ++StrCountMeter; StrVolumeMeter += *gross_size; return pool ? pool->alloc() : xcalloc(1, net_size); @@ -274,7 +270,6 @@ memFreeString(size_t size, void *buf) if (type != MEM_NONE) pool = GetStrPool(type); - // may forget [de]allocations until MemIsInitialized --StrCountMeter; StrVolumeMeter -= size; pool ? pool->freeOne(buf) : xfree(buf); @@ -415,6 +410,11 @@ memConfigure(void) void Mem::Init(void) { + /* all pools are ready to be used */ + static bool MemIsInitialized = false; + if (MemIsInitialized) + return; + /** \par * NOTE: Mem::Init() is called before the config file is parsed * and before the debugging module has been initialized. Any