]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mem/AllocatorProxy.cc
Merge from trunk rev.13866
[thirdparty/squid.git] / src / mem / AllocatorProxy.cc
1 /*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #include "squid.h"
10 #include "mem/AllocatorProxy.h"
11 #include "mem/Pool.h"
12
13 void *
14 Mem::AllocatorProxy::alloc()
15 {
16 return getAllocator()->alloc();
17 }
18
19 void
20 Mem::AllocatorProxy::freeOne(void *address)
21 {
22 getAllocator()->freeOne(address);
23 /* TODO: check for empty, and if so, if the default type has altered,
24 * switch
25 */
26 }
27
28 MemAllocator *
29 Mem::AllocatorProxy::getAllocator() const
30 {
31 if (!theAllocator)
32 theAllocator = MemPools::GetInstance().create(objectType(), size);
33 return theAllocator;
34 }
35
36 int
37 Mem::AllocatorProxy::inUseCount() const
38 {
39 if (!theAllocator)
40 return 0;
41 else
42 return memPoolInUseCount(theAllocator);
43 }
44
45 MemPoolMeter const &
46 Mem::AllocatorProxy::getMeter() const
47 {
48 return getAllocator()->getMeter();
49 }
50
51 int
52 Mem::AllocatorProxy::getStats(MemPoolStats * stats)
53 {
54 return getAllocator()->getStats(stats);
55 }
56