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

 

Introduction

Documentation

Support

Miscellaneous