stub_libmem.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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
17void *Mem::AllocatorProxy::alloc() {return xmalloc(64*1024);}
18void Mem::AllocatorProxy::freeOne(void *address) {xfree(address);}
19int 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"
26void Mem::Report() STUB_NOP
28void Mem::CleanIdlePools(void *) STUB_NOP
29void Mem::Report(std::ostream &) STUB_NOP
30void Mem::PoolReport(const MemPoolStats *, const MemPoolMeter *, std::ostream &) STUB_NOP
31//const size_t squidSystemPageSize = 4096;
32void memClean(void) STUB
33void memInitModule(void) STUB
34void memCleanModule(void) STUB
35void memConfigure(void) STUB
36
38{
39 // let's waste plenty of memory. This should cover any possible need
40 return xmalloc(64*1024);
41}
42
43void *memAllocString(size_t net_size, size_t * gross_size) {return memAllocBuf(net_size, gross_size);}
44
45void *memAllocRigid(size_t net_size)
46{
47 return xmalloc(net_size);
48}
49
50void *
51memAllocBuf(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 */
60void *
61memReallocBuf(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
70void memFree(void *p, int) {xfree(p);}
71void memFreeString(size_t, void *buf) {xfree(buf);}
72void memFreeRigid(void *buf, size_t) {xfree(buf);}
73void memFreeBuf(size_t, void *buf) {xfree(buf);}
74static void cxx_xfree(void * ptr) {xfree(ptr);}
75FREE *memFreeBufFunc(size_t) {return cxx_xfree;}
77void memDataInit(mem_type, const char *, size_t, int, bool) STUB_NOP
78void memCheckInit(void) STUB_NOP
79
80#include "mem/Pool.h"
82void MemPoolMeter::flush() STUB
83static MemPools tmpMemPools;
84MemPools &MemPools::GetInstance() {return tmpMemPools;}
86 pools(nullptr),
87 mem_idle_limit(0),
88 poolCount(0),
89 defaultIsChunked(false)
90{}
92MemImplementingAllocator * MemPools::create(const char *, size_t) STUB_RETVAL(nullptr);
93void MemPools::setIdleLimit(ssize_t) STUB
94ssize_t MemPools::idleLimit() const STUB_RETVAL(0)
95void MemPools::clean(time_t) STUB
96void MemPools::setDefaultPoolChunking(bool const &) STUB
97
98//MemAllocator::MemAllocator(char const *aLabel);
99char const *MemAllocator::objectType() const STUB_RETVAL(nullptr)
100int MemAllocator::inUseCount() STUB_RETVAL(0)
101size_t MemAllocator::RoundedSize(size_t minSize) STUB_RETVAL(minSize)
102
103//MemImplementingAllocator::MemImplementingAllocator(char const *, size_t) STUB_NOP
104//MemImplementingAllocator::~MemImplementingAllocator();
107void MemImplementingAllocator::flushMetersFull() STUB
108void MemImplementingAllocator::flushMeters() STUB
109void *MemImplementingAllocator::alloc() STUB_RETVAL(nullptr)
110void MemImplementingAllocator::freeOne(void *) STUB
111
117
#define false
Definition: GnuRegex.c:240
#define STUB
macro to stub a void function.
Definition: STUB.h:33
#define STUB_NOP
Definition: STUB.h:37
#define STUB_RETSTATREF(x)
Definition: STUB.h:54
#define STUB_RETVAL(x)
Definition: STUB.h:41
MemPoolMeter()
Definition: Pool.cc:164
Definition: Pool.h:117
MemPools()
Definition: Pool.cc:83
void flushMeters()
Definition: Pool.cc:173
void * alloc()
Allocate one element from the pool.
void freeOne(void *)
Free a element allocated by Mem::AllocatorProxy::alloc()
int inUseCount() const
int getStats(MemPoolStats *stats)
MemPoolIterator * memPoolIterate(void)
Definition: Pool.cc:39
void memPoolIterateDone(MemPoolIterator **iter)
Definition: Pool.cc:46
int memPoolsTotalAllocated(void)
Definition: Pool.cc:298
MemImplementingAllocator * memPoolIterateNext(MemPoolIterator *iter)
Definition: Pool.cc:54
int memPoolGetGlobalStats(MemPoolGlobalStats *stats)
Definition: Pool.cc:249
void memCleanModule(void)
void FREE(void *)
Definition: forward.h:36
void memClean(void)
Main cleanup handler.
Definition: old_api.cc:494
void * memAllocate(mem_type)
Allocate one element from the typed pool.
Definition: old_api.cc:213
void memDataInit(mem_type, const char *, size_t, int, bool doZero=true)
Definition: old_api.cc:200
void memCheckInit(void)
Definition: stub_libmem.cc:84
void memInitModule(void)
mem_type
Types of memory pool which do not yet use MEMPROXY_CLASS() API.
Definition: forward.h:39
void memConfigure(void)
Definition: old_api.cc:406
Memory Management.
void Init()
Definition: old_api.cc:425
void Report()
Definition: old_api.cc:460
void PoolReport(const MemPoolStats *mp_st, const MemPoolMeter *AllMeter, std::ostream &)
Definition: old_api.cc:591
void CleanIdlePools(void *unused)
Definition: old_api.cc:399
void Stats(StoreEntry *)
Definition: old_api.cc:165
STL namespace.
#define xfree
#define xmalloc
void * memReallocBuf(void *oldbuf, size_t net_size, size_t *gross_size)
Definition: stub_libmem.cc:61
void * memAllocBuf(size_t net_size, size_t *gross_size)
Definition: stub_libmem.cc:51
void memFreeBuf(size_t, void *buf)
Definition: stub_libmem.cc:73
static void cxx_xfree(void *ptr)
Definition: stub_libmem.cc:74
void memFreeRigid(void *buf, size_t)
Definition: stub_libmem.cc:72
int memInUse(mem_type) STUB_RETVAL(0) void memDataInit(mem_type
Definition: old_api.cc:509
void memFree(void *p, int)
Free a element allocated by memAllocate()
Definition: stub_libmem.cc:70
void * memAllocRigid(size_t net_size)
Definition: stub_libmem.cc:45
FREE * memFreeBufFunc(size_t)
Definition: stub_libmem.cc:75
void * memAllocString(size_t net_size, size_t *gross_size)
Definition: stub_libmem.cc:43
void memFreeString(size_t, void *buf)
Definition: stub_libmem.cc:71
void * xrealloc(void *s, size_t sz)
Definition: xalloc.cc:126
void * xcalloc(size_t n, size_t sz)
Definition: xalloc.cc:71

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors