]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mem/AllocatorProxy.cc
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / mem / AllocatorProxy.cc
CommitLineData
eac61ce1 1/*
b8ae064d 2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
eac61ce1
AJ
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
ed6e9fb9
AJ
9#include "squid.h"
10#include "mem/AllocatorProxy.h"
09c020f2 11#include "mem/Meter.h"
ed6e9fb9 12#include "mem/Pool.h"
a7508376 13#include "mem/Stats.h"
ed6e9fb9
AJ
14
15void *
16Mem::AllocatorProxy::alloc()
17{
18 return getAllocator()->alloc();
19}
20
21void
22Mem::AllocatorProxy::freeOne(void *address)
23{
24 getAllocator()->freeOne(address);
25 /* TODO: check for empty, and if so, if the default type has altered,
26 * switch
27 */
28}
29
341876ec 30Mem::Allocator *
ed6e9fb9
AJ
31Mem::AllocatorProxy::getAllocator() const
32{
341d719c 33 if (!theAllocator) {
ed6e9fb9 34 theAllocator = MemPools::GetInstance().create(objectType(), size);
341d719c
FC
35 theAllocator->zeroBlocks(doZero);
36 }
ed6e9fb9
AJ
37 return theAllocator;
38}
39
40int
41Mem::AllocatorProxy::inUseCount() const
42{
43 if (!theAllocator)
44 return 0;
45 else
e8dcf312 46 return theAllocator->inUseCount();
ed6e9fb9
AJ
47}
48
341d719c
FC
49void
50Mem::AllocatorProxy::zeroBlocks(bool doIt)
51{
1a739503 52 getAllocator()->zeroBlocks(doIt);
341d719c
FC
53}
54
09c020f2 55Mem::PoolMeter const &
ed6e9fb9
AJ
56Mem::AllocatorProxy::getMeter() const
57{
58 return getAllocator()->getMeter();
59}
60
a7508376
AJ
61size_t
62Mem::AllocatorProxy::getStats(PoolStats &stats)
ed6e9fb9
AJ
63{
64 return getAllocator()->getStats(stats);
65}
f53969cc 66