stub_libmem.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 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 
11 #define STUB_API "mem/libmem.la"
12 #include "tests/STUB.h"
13 
14 #include "mem/AllocatorProxy.h"
15 #include "mem/forward.h"
16 
17 void *Mem::AllocatorProxy::alloc() {return xmalloc(64*1024);}
18 void Mem::AllocatorProxy::freeOne(void *address) {xfree(address);}
19 int Mem::AllocatorProxy::inUseCount() const {return 0;}
20 //static MemPoolMeter tmpMemPoolMeter;
21 //MemPoolMeter const &Mem::AllocatorProxy::getMeter() const STUB_RETVAL(tmpMemPoolMeter)
23 
24 #include "mem/forward.h"
25 void Mem::Init() STUB_NOP
26 void Mem::Report() STUB_NOP
28 void Mem::CleanIdlePools(void *) STUB_NOP
29 void Mem::Report(std::ostream &) STUB_NOP
30 void Mem::PoolReport(const MemPoolStats *, const MemPoolMeter *, std::ostream &) STUB_NOP
31 //const size_t squidSystemPageSize = 4096;
32 void memClean(void) STUB
33 void memInitModule(void) STUB
34 void memCleanModule(void) STUB
35 void memConfigure(void) STUB
36 
37 void *memAllocate(mem_type)
38 {
39  // let's waste plenty of memory. This should cover any possible need
40  return xmalloc(64*1024);
41 }
42 
43 void *memAllocString(size_t net_size, size_t * gross_size) {return memAllocBuf(net_size, gross_size);}
44 
45 void *memAllocRigid(size_t net_size)
46 {
47  return xmalloc(net_size);
48 }
49 
50 void *
51 memAllocBuf(size_t net_size, size_t * gross_size)
52 {
53  *gross_size=net_size;
54  return xcalloc(1, net_size);
55 }
56 
57 /* net_size is the new size, *gross size is the old gross size, to be changed to
58  * the new gross size as a side-effect.
59  */
60 void *
61 memReallocBuf(void *oldbuf, size_t net_size, size_t * gross_size)
62 {
63  void *rv=xrealloc(oldbuf,net_size);
64 // if (net_size > *gross_size)
65 // memset(rv+net_size,0,net_size-*gross_size);
66  *gross_size=net_size;
67  return rv;
68 }
69 
70 void memFree(void *p, int) {xfree(p);}
71 void memFreeString(size_t, void *buf) {xfree(buf);}
72 void memFreeRigid(void *buf, size_t) {xfree(buf);}
73 void memFreeBuf(size_t, void *buf) {xfree(buf);}
74 static void cxx_xfree(void * ptr) {xfree(ptr);}
75 FREE *memFreeBufFunc(size_t) {return cxx_xfree;}
77 void memDataInit(mem_type, const char *, size_t, int, bool) STUB_NOP
78 void memCheckInit(void) STUB_NOP
79 
80 #include "mem/Pool.h"
82 void MemPoolMeter::flush() STUB
83 static MemPools tmpMemPools;
84 MemPools &MemPools::GetInstance() {return tmpMemPools;}
86  pools(nullptr),
87  mem_idle_limit(0),
88  poolCount(0),
89  defaultIsChunked(false)
90 {}
92 MemImplementingAllocator * MemPools::create(const char *, size_t) STUB_RETVAL(nullptr);
93 void MemPools::setIdleLimit(ssize_t) STUB
94 ssize_t MemPools::idleLimit() const STUB_RETVAL(0)
95 void MemPools::clean(time_t) STUB
96 void MemPools::setDefaultPoolChunking(bool const &) STUB
97 
98 //MemAllocator::MemAllocator(char const *aLabel);
99 char const *MemAllocator::objectType() const STUB_RETVAL(nullptr)
100 int MemAllocator::inUseCount() STUB_RETVAL(0)
101 size_t MemAllocator::RoundedSize(size_t minSize) STUB_RETVAL(minSize)
102 
103 //MemImplementingAllocator::MemImplementingAllocator(char const *, size_t) STUB_NOP
104 //MemImplementingAllocator::~MemImplementingAllocator();
107 void MemImplementingAllocator::flushMetersFull() STUB
108 void MemImplementingAllocator::flushMeters() STUB
109 void *MemImplementingAllocator::alloc() STUB_RETVAL(nullptr)
110 void MemImplementingAllocator::freeOne(void *) STUB
111 
117 
void freeOne(void *)
Free a element allocated by Mem::AllocatorProxy::alloc()
void * memAllocBuf(size_t net_size, size_t *gross_size)
Definition: stub_libmem.cc:51
void * xcalloc(size_t n, size_t sz)
Definition: xalloc.cc:71
void memFree(void *p, int)
Free a element allocated by memAllocate()
Definition: stub_libmem.cc:70
#define xmalloc
int getStats(MemPoolStats *stats)
void memClean(void)
Main cleanup handler.
Definition: old_api.cc:502
int inUseCount() const
void * memAllocString(size_t net_size, size_t *gross_size)
Definition: stub_libmem.cc:43
void * alloc()
Allocate one element from the pool.
void FREE(void *)
Definition: forward.h:36
void memPoolIterateDone(MemPoolIterator **iter)
Definition: Pool.cc:47
#define STUB_RETVAL(x)
Definition: STUB.h:41
mem_type
Types of memory pool which do not yet use MEMPROXY_CLASS() API.
Definition: forward.h:39
FREE * memFreeBufFunc(size_t)
Definition: stub_libmem.cc:75
int memPoolGetGlobalStats(MemPoolGlobalStats *stats)
Definition: Pool.cc:250
void * memAllocate(mem_type)
Allocate one element from the typed pool.
Definition: old_api.cc:214
MemImplementingAllocator * memPoolIterateNext(MemPoolIterator *iter)
Definition: Pool.cc:55
MemPools()
Definition: Pool.cc:84
void memDataInit(mem_type, const char *, size_t, int, bool doZero=true)
Definition: old_api.cc:201
void memCleanModule(void)
Memory Management.
void memCheckInit(void)
Definition: stub_libmem.cc:84
MemPoolIterator * memPoolIterate(void)
Definition: Pool.cc:40
void Stats(StoreEntry *)
Definition: old_api.cc:166
void memConfigure(void)
Definition: old_api.cc:407
void * memAllocRigid(size_t net_size)
Definition: stub_libmem.cc:45
#define STUB_RETSTATREF(x)
Definition: STUB.h:54
void Report()
Definition: old_api.cc:468
int memPoolsTotalAllocated(void)
Definition: Pool.cc:299
void * memReallocBuf(void *oldbuf, size_t net_size, size_t *gross_size)
Definition: stub_libmem.cc:61
#define STUB
macro to stub a void function.
Definition: STUB.h:33
void memFreeRigid(void *buf, size_t)
Definition: stub_libmem.cc:72
void memFreeBuf(size_t, void *buf)
Definition: stub_libmem.cc:73
#define xfree
int memInUse(mem_type) STUB_RETVAL(0) void memDataInit(mem_type
Definition: old_api.cc:517
static void cxx_xfree(void *ptr)
Definition: stub_libmem.cc:74
void memInitModule(void)
void PoolReport(const MemPoolStats *mp_st, const MemPoolMeter *AllMeter, std::ostream &)
Definition: old_api.cc:599
#define STUB_NOP
Definition: STUB.h:37
void Init()
Definition: old_api.cc:426
void CleanIdlePools(void *unused)
Definition: old_api.cc:400
Definition: Pool.h:117
void memFreeString(size_t, void *buf)
Definition: stub_libmem.cc:71
void flushMeters()
Definition: Pool.cc:174
MemPoolMeter()
Definition: Pool.cc:165
#define false
Definition: GnuRegex.c:233
void * xrealloc(void *s, size_t sz)
Definition: xalloc.cc:126

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors