]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/mem/PoolChunked.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / mem / PoolChunked.cc
index cee007256fe5b1c5eb247bc49509da8a53ad99f0..b630c227fcd190b9189d84e7aab26891ada9e6b8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -135,16 +135,11 @@ MemChunk::MemChunk(MemPoolChunked *aPool)
     pool->allChunks.insert(this, memCompChunks);
 }
 
-MemPoolChunked::MemPoolChunked(const char *aLabel, size_t aSize) : MemImplementingAllocator(aLabel, aSize)
+MemPoolChunked::MemPoolChunked(const char *aLabel, size_t aSize) :
+    MemImplementingAllocator(aLabel, aSize) , chunk_size(0),
+    chunk_capacity(0), chunkCount(0), freeCache(0), nextFreeChunk(0),
+    Chunks(0), allChunks(Splay<MemChunk *>())
 {
-    chunk_size = 0;
-    chunk_capacity = 0;
-    chunkCount = 0;
-    freeCache = 0;
-    nextFreeChunk = 0;
-    Chunks = 0;
-    next = 0;
-
     setChunkSize(MEM_CHUNK_SIZE);
 
 #if HAVE_MALLOPT && M_MMAP_MAX
@@ -231,7 +226,7 @@ MemPoolChunked::createChunk()
     newChunk = new MemChunk(this);
 
     chunk = Chunks;
-    if (chunk == NULL) {       /* first chunk in pool */
+    if (chunk == NULL) {    /* first chunk in pool */
         Chunks = newChunk;
         return;
     }
@@ -260,10 +255,10 @@ MemPoolChunked::setChunkSize(size_t chunksize)
     int cap;
     size_t csize = chunksize;
 
-    if (Chunks)                /* unsafe to tamper */
+    if (Chunks)     /* unsafe to tamper */
         return;
 
-    csize = ((csize + MEM_PAGE_SIZE - 1) / MEM_PAGE_SIZE) * MEM_PAGE_SIZE;     /* round up to page size */
+    csize = ((csize + MEM_PAGE_SIZE - 1) / MEM_PAGE_SIZE) * MEM_PAGE_SIZE;  /* round up to page size */
     cap = csize / obj_size;
 
     if (cap < MEM_MIN_FREE)
@@ -276,7 +271,7 @@ MemPoolChunked::setChunkSize(size_t chunksize)
         cap = 1;
 
     csize = cap * obj_size;
-    csize = ((csize + MEM_PAGE_SIZE - 1) / MEM_PAGE_SIZE) * MEM_PAGE_SIZE;     /* round up to page size */
+    csize = ((csize + MEM_PAGE_SIZE - 1) / MEM_PAGE_SIZE) * MEM_PAGE_SIZE;  /* round up to page size */
     cap = csize / obj_size;
 
     chunk_capacity = cap;
@@ -321,7 +316,7 @@ MemPoolChunked::allocate()
 }
 
 void
-MemPoolChunked::deallocate(void *obj, bool aggressive)
+MemPoolChunked::deallocate(void *obj, bool)
 {
     push(obj);
     assert(meter.inuse.level > 0);
@@ -345,8 +340,8 @@ MemPoolChunked::convertFreeCacheToChunkFreeCache()
         assert(chunk->inuse_count > 0);
         -- chunk->inuse_count;
         (void) VALGRIND_MAKE_MEM_DEFINED(Free, sizeof(void *));
-        freeCache = *(void **)Free;    /* remove from global cache */
-        *(void **)Free = chunk->freeList;      /* stuff into chunks freelist */
+        freeCache = *(void **)Free; /* remove from global cache */
+        *(void **)Free = chunk->freeList;   /* stuff into chunks freelist */
         (void) VALGRIND_MAKE_MEM_NOACCESS(Free, sizeof(void *));
         chunk->freeList = Free;
         chunk->lastref = squid_curtime;
@@ -435,10 +430,10 @@ MemPoolChunked::getStats(MemPoolStats * stats, int accumulate)
     int chunks_free = 0;
     int chunks_partial = 0;
 
-    if (!accumulate)   /* need skip memset for GlobalStats accumulation */
+    if (!accumulate)    /* need skip memset for GlobalStats accumulation */
         memset(stats, 0, sizeof(MemPoolStats));
 
-    clean((time_t) 555555);    /* don't want to get chunks released before reporting */
+    clean((time_t) 555555); /* don't want to get chunks released before reporting */
 
     stats->pool = this;
     stats->label = objectType();
@@ -469,3 +464,4 @@ MemPoolChunked::getStats(MemPoolStats * stats, int accumulate)
 
     return meter.inuse.level;
 }
+