AllocatorProxy.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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/Allocator.h"
11 #include "mem/AllocatorProxy.h"
12 #include "mem/Pool.h"
13 #include "mem/Stats.h"
14 
15 void *
17 {
18  return getAllocator()->alloc();
19 }
20 
21 void
23 {
24  getAllocator()->freeOne(address);
25  /* TODO: check for empty, and if so, if the default type has altered,
26  * switch
27  */
28 }
29 
32 {
33  if (!theAllocator) {
34  theAllocator = MemPools::GetInstance().create(objectType(), size);
35  theAllocator->zeroBlocks(doZero);
36  }
37  return theAllocator;
38 }
39 
40 int
42 {
43  if (!theAllocator)
44  return 0;
45  else
46  return theAllocator->getInUseCount();
47 }
48 
49 void
51 {
52  getAllocator()->zeroBlocks(doIt);
53 }
54 
55 void
56 Mem::AllocatorProxy::relabel(const char * const aLabel)
57 {
58  getAllocator()->relabel(aLabel);
59  label = aLabel;
60 }
61 
62 Mem::PoolMeter const &
64 {
65  return getAllocator()->meter;
66 }
67 
68 size_t
70 {
71  return getAllocator()->getStats(stats);
72 }
73 
void freeOne(void *)
Free a element allocated by Mem::AllocatorProxy::alloc()
size_t getStats(PoolStats &stats)
int inUseCount() const
void * alloc()
Allocate one element from the pool.
void * alloc()
provide (and reserve) memory suitable for storing one object
Definition: Allocator.h:44
void zeroBlocks(const bool doIt)
Definition: Allocator.h:62
int size
Definition: ModDevPoll.cc:69
Allocator * getAllocator() const
const PoolMeter & getMeter() const
static MemPools & GetInstance()
Definition: Pool.cc:27
void zeroBlocks(bool doIt)
void relabel(const char *const aLabel)
Mem::Allocator * create(const char *, size_t)
Definition: Pool.cc:47

 

Introduction

Documentation

Support

Miscellaneous