Squid Web Cache master
Loading...
Searching...
No Matches
minimal.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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/AllocatorProxy.h"
11#include "mem/forward.h"
12
17static int Alive = 0;
18
19void *
21{
22 const auto memory = doZero ? xcalloc(1, size) : xmalloc(size);
23 ++Alive;
24 return memory;
25}
26
27void
28Mem::AllocatorProxy::freeOne(void *memory) {
29 xfree(memory);
30 --Alive;
31}
32
33int
35{
36 return Alive;
37}
38
39size_t
41{
42 return Alive;
43}
44
45void *
46memAllocBuf(const size_t netSize, size_t * const grossSize)
47{
48 if (grossSize)
49 *grossSize = netSize;
50 return xmalloc(netSize);
51}
52
53void *
54memReallocBuf(void * const oldBuf, const size_t netSize, size_t * const grossSize)
55{
56 *grossSize = netSize;
57 return xrealloc(oldBuf, netSize);
58}
59
60void
61memFree(void *memory, int)
62{
63 xfree(memory);
64}
65
66void
67memFreeBuf(size_t, void * const buf)
68{
69 xfree(buf);
70}
71
72static void
73myFree(void * const buf)
74{
75 xfree(buf);
76}
77
78FREE *
80{
81 return &myFree;
82}
83
void * alloc()
Allocate one element from the pool.
void freeOne(void *)
Free a element allocated by Mem::AllocatorProxy::alloc()
size_t getStats(PoolStats &stats)
void FREE(void *)
Definition forward.h:37
void memFreeBuf(size_t size, void *)
Definition minimal.cc:67
void memFree(void *, int type)
Free a element allocated by memAllocate()
Definition minimal.cc:61
void * memAllocBuf(size_t net_size, size_t *gross_size)
Definition minimal.cc:46
void * memReallocBuf(void *buf, size_t net_size, size_t *gross_size)
Definition minimal.cc:54
FREE * memFreeBufFunc(size_t size)
Definition minimal.cc:79
static int Alive
Definition minimal.cc:17
static void myFree(void *const buf)
Definition minimal.cc:73
#define xfree
#define xmalloc
void * xrealloc(void *s, size_t sz)
Definition xalloc.cc:126
void * xcalloc(size_t n, size_t sz)
Definition xalloc.cc:71