]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/mem/PoolMalloc.cc
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / mem / PoolMalloc.cc
index 39cc997ca95a9c1a5f5b9f47752a00825b2ad743..f5601c78ada8597b83f0a9ab6d47fd2349244590 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -7,12 +7,12 @@
  */
 
 /*
- * DEBUG: section 63    Low Level Memory Pool Management
  * AUTHOR: Alex Rousskov, Andres Kroonmaa, Robert Collins, Henrik Nordstrom
  */
 
 #include "squid.h"
 #include "mem/PoolMalloc.h"
+#include "mem/Stats.h"
 
 #include <cassert>
 #include <cstring>
@@ -22,7 +22,7 @@ extern time_t squid_curtime;
 void *
 MemPoolMalloc::allocate()
 {
-    void *obj = NULL;
+    void *obj = nullptr;
     if (!freelist.empty()) {
         obj = freelist.top();
         freelist.pop();
@@ -57,28 +57,25 @@ MemPoolMalloc::deallocate(void *obj, bool aggressive)
 }
 
 /* TODO extract common logic to MemAllocate */
-int
-MemPoolMalloc::getStats(MemPoolStats * stats, int accumulate)
+size_t
+MemPoolMalloc::getStats(Mem::PoolStats &stats)
 {
-    if (!accumulate)    /* need skip memset for GlobalStats accumulation */
-        memset(stats, 0, sizeof(MemPoolStats));
-
-    stats->pool = this;
-    stats->label = objectType();
-    stats->meter = &meter;
-    stats->obj_size = obj_size;
-    stats->chunk_capacity = 0;
-
-    stats->chunks_alloc += 0;
-    stats->chunks_inuse += 0;
-    stats->chunks_partial += 0;
-    stats->chunks_free += 0;
-
-    stats->items_alloc += meter.alloc.currentLevel();
-    stats->items_inuse += meter.inuse.currentLevel();
-    stats->items_idle += meter.idle.currentLevel();
-
-    stats->overhead += sizeof(MemPoolMalloc) + strlen(objectType()) + 1;
+    stats.pool = this;
+    stats.label = objectType();
+    stats.meter = &meter;
+    stats.obj_size = obj_size;
+    stats.chunk_capacity = 0;
+
+    stats.chunks_alloc += 0;
+    stats.chunks_inuse += 0;
+    stats.chunks_partial += 0;
+    stats.chunks_free += 0;
+
+    stats.items_alloc += meter.alloc.currentLevel();
+    stats.items_inuse += meter.inuse.currentLevel();
+    stats.items_idle += meter.idle.currentLevel();
+
+    stats.overhead += sizeof(MemPoolMalloc) + strlen(objectType()) + 1;
 
     return meter.inuse.currentLevel();
 }