]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mem/AllocatorProxy.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / mem / AllocatorProxy.cc
1 /*
2 * Copyright (C) 1996-2020 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 theAllocator->zeroBlocks(doZero);
34 }
35 return theAllocator;
36 }
37
38 int
39 Mem::AllocatorProxy::inUseCount() const
40 {
41 if (!theAllocator)
42 return 0;
43 else
44 return theAllocator->inUseCount();
45 }
46
47 void
48 Mem::AllocatorProxy::zeroBlocks(bool doIt)
49 {
50 getAllocator()->zeroBlocks(doIt);
51 }
52
53 MemPoolMeter const &
54 Mem::AllocatorProxy::getMeter() const
55 {
56 return getAllocator()->getMeter();
57 }
58
59 int
60 Mem::AllocatorProxy::getStats(MemPoolStats * stats)
61 {
62 return getAllocator()->getStats(stats);
63 }
64