/*
- * 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.
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
newChunk = new MemChunk(this);
chunk = Chunks;
- if (chunk == NULL) { /* first chunk in pool */
+ if (chunk == NULL) { /* first chunk in pool */
Chunks = newChunk;
return;
}
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)
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;
}
void
-MemPoolChunked::deallocate(void *obj, bool aggressive)
+MemPoolChunked::deallocate(void *obj, bool)
{
push(obj);
assert(meter.inuse.level > 0);
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;
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();
return meter.inuse.level;
}
+