minimal.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/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 *grossSize = netSize;
49 return xcalloc(1, netSize);
50}
51
52void *
53memReallocBuf(void * const oldBuf, const size_t netSize, size_t * const grossSize)
54{
55 *grossSize = netSize;
56 return xrealloc(oldBuf, netSize);
57}
58
59void
60memFree(void *memory, int)
61{
62 xfree(memory);
63}
64
65void *
66memAllocString(const size_t netSize, size_t * const grossSize)
67{
68 return memAllocBuf(netSize, grossSize);
69}
70
71void
72memFreeString(size_t, void *memory)
73{
74 xfree(memory);
75}
76
77void *
78memAllocRigid(const size_t netSize)
79{
80 return xmalloc(netSize);
81}
82
83void
84memFreeRigid(void * const buf, size_t)
85{
86 xfree(buf);
87}
88
89void
90memFreeBuf(size_t, void * const buf)
91{
92 xfree(buf);
93}
94
95static void
96myFree(void * const buf)
97{
98 xfree(buf);
99}
100
101FREE *
103{
104 return &myFree;
105}
106
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 FREE(void *)
Definition: forward.h:37
static int Alive
Definition: minimal.cc:17
static void myFree(void *const buf)
Definition: minimal.cc:96
void memFreeString(size_t, void *memory)
Definition: minimal.cc:72
void memFree(void *memory, int)
Free a element allocated by memAllocate()
Definition: minimal.cc:60
void * memAllocRigid(const size_t netSize)
Definition: minimal.cc:78
void * memAllocString(const size_t netSize, size_t *const grossSize)
Definition: minimal.cc:66
void memFreeBuf(size_t, void *const buf)
Definition: minimal.cc:90
void * memAllocBuf(const size_t netSize, size_t *const grossSize)
Definition: minimal.cc:46
void memFreeRigid(void *const buf, size_t)
Definition: minimal.cc:84
void * memReallocBuf(void *const oldBuf, const size_t netSize, size_t *const grossSize)
Definition: minimal.cc:53
FREE * memFreeBufFunc(size_t)
Definition: minimal.cc:102
#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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors