stub_libmem.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
11#define STUB_API "mem/libmem.la"
12#include "tests/STUB.h"
13
14#include "mem/Allocator.h"
15
16#include "mem/AllocatorProxy.h"
17#include "mem/forward.h"
18
19void *Mem::AllocatorProxy::alloc() {return xmalloc(64*1024);}
20void Mem::AllocatorProxy::freeOne(void *address) {xfree(address);}
21int Mem::AllocatorProxy::inUseCount() const {return 0;}
22size_t Mem::AllocatorProxy::getStats(PoolStats &) STUB_RETVAL(0)
23
24#include "mem/forward.h"
27void Mem::CleanIdlePools(void *) STUB_NOP
28void Mem::Report(std::ostream &) STUB_NOP
29void Mem::PoolReport(const PoolStats *, const PoolMeter *, std::ostream &) STUB_NOP
30//const size_t squidSystemPageSize = 4096;
31void memClean(void) STUB
32void memInitModule(void) STUB
33void memCleanModule(void) STUB
34void memConfigure(void) STUB
35
37{
38 // let's waste plenty of memory. This should cover any possible need
39 return xmalloc(64*1024);
40}
41
42void *memAllocString(size_t net_size, size_t * gross_size) {return memAllocBuf(net_size, gross_size);}
43
44void *memAllocRigid(size_t net_size)
45{
46 return xmalloc(net_size);
47}
48
49void *
50memAllocBuf(size_t net_size, size_t * gross_size)
51{
52 *gross_size=net_size;
53 return xcalloc(1, net_size);
54}
55
56/* net_size is the new size, *gross size is the old gross size, to be changed to
57 * the new gross size as a side-effect.
58 */
59void *
60memReallocBuf(void *oldbuf, size_t net_size, size_t * gross_size)
61{
62 void *rv=xrealloc(oldbuf,net_size);
63// if (net_size > *gross_size)
64// memset(rv+net_size,0,net_size-*gross_size);
65 *gross_size=net_size;
66 return rv;
67}
68
69void memFree(void *p, int) {xfree(p);}
70void memFreeString(size_t, void *buf) {xfree(buf);}
71void memFreeRigid(void *buf, size_t) {xfree(buf);}
72void memFreeBuf(size_t, void *buf) {xfree(buf);}
73static void cxx_xfree(void * ptr) {xfree(ptr);}
74FREE *memFreeBufFunc(size_t) {return cxx_xfree;}
76void memDataInit(mem_type, const char *, size_t, int, bool) STUB_NOP
77void memCheckInit(void) STUB_NOP
78
79#include "mem/Pool.h"
80static MemPools tmpMemPools;
81MemPools &MemPools::GetInstance() {return tmpMemPools;}
83void MemPools::flushMeters() STUB
84Mem::Allocator * MemPools::create(const char *, size_t) STUB_RETVAL(nullptr);
85void MemPools::clean(time_t) STUB
86void MemPools::setDefaultPoolChunking(bool const &) STUB
87
88#include "mem/Stats.h"
89size_t Mem::GlobalStats(PoolStats &) STUB_RETVAL(0)
#define STUB
macro to stub a void function.
Definition: STUB.h:33
#define STUB_NOP
Definition: STUB.h:37
#define STUB_RETVAL(x)
Definition: STUB.h:41
Definition: Pool.h:61
MemPools()
Definition: Pool.cc:40
static MemPools & GetInstance()
Definition: Pool.cc:27
void * alloc()
Allocate one element from the pool.
void freeOne(void *)
Free a element allocated by Mem::AllocatorProxy::alloc()
int inUseCount() const
size_t getStats(PoolStats &stats)
void memCleanModule(void)
void FREE(void *)
Definition: forward.h:37
void memClean(void)
Main cleanup handler.
Definition: old_api.cc:485
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 memInitModule(void)
mem_type
Types of memory pool which do not yet use MEMPROXY_CLASS() API.
Definition: forward.h:40
void memConfigure(void)
Definition: old_api.cc:406
Memory Management.
Definition: Allocator.h:17
size_t GlobalStats(PoolStats &)
Definition: Stats.cc:15
void PoolReport(const PoolStats *, const PoolMeter *, std::ostream &)
Definition: old_api.cc:581
void Init()
Definition: old_api.cc:425
void Report(std::ostream &)
Definition: old_api.cc:651
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:60
int const char bool STUB_NOP void memCheckInit(void) STUB_NOP static MemPools tmpMemPools
Definition: old_api.cc:471
void * memAllocBuf(size_t net_size, size_t *gross_size)
Definition: stub_libmem.cc:50
void memFreeBuf(size_t, void *buf)
Definition: stub_libmem.cc:72
static void cxx_xfree(void *ptr)
Definition: stub_libmem.cc:73
void memFreeRigid(void *buf, size_t)
Definition: stub_libmem.cc:71
int memInUse(mem_type) STUB_RETVAL(0) void memDataInit(mem_type
Definition: old_api.cc:501
void memFree(void *p, int)
Free a element allocated by memAllocate()
Definition: stub_libmem.cc:69
void * memAllocRigid(size_t net_size)
Definition: stub_libmem.cc:44
FREE * memFreeBufFunc(size_t)
Definition: stub_libmem.cc:74
void * memAllocString(size_t net_size, size_t *gross_size)
Definition: stub_libmem.cc:42
void memFreeString(size_t, void *buf)
Definition: stub_libmem.cc:70
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