]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Reduce scope of MemIsInitialized
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 24 Mar 2016 10:12:23 +0000 (23:12 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 24 Mar 2016 10:12:23 +0000 (23:12 +1300)
src/mem/old_api.cc

index b9d28b5db8e55709becae7808ce74e5ddb1ca036..3ef4419885a1b2a54f4759a02d33a58729df33d1 100644 (file)
@@ -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