minimal.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 #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 int
41 {
42  return Alive;
43 }
44 
45 void *
46 memAllocBuf(const size_t netSize, size_t * const grossSize)
47 {
48  *grossSize = netSize;
49  return xcalloc(1, netSize);
50 }
51 
52 void *
53 memReallocBuf(void * const oldBuf, const size_t netSize, size_t * const grossSize)
54 {
55  *grossSize = netSize;
56  return xrealloc(oldBuf, netSize);
57 }
58 
59 void
60 memFree(void *memory, int)
61 {
62  xfree(memory);
63 }
64 
65 void *
66 memAllocString(const size_t netSize, size_t * const grossSize)
67 {
68  return memAllocBuf(netSize, grossSize);
69 }
70 
71 void
72 memFreeString(size_t, void *memory)
73 {
74  xfree(memory);
75 }
76 
77 void *
78 memAllocRigid(const size_t netSize)
79 {
80  return xmalloc(netSize);
81 }
82 
83 void
84 memFreeBuf(size_t, void * const buf)
85 {
86  xfree(buf);
87 }
88 
89 static void
90 myFree(void * const buf)
91 {
92  xfree(buf);
93 }
94 
95 FREE *
97 {
98  return &myFree;
99 }
100 
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)
void FREE(void *)
Definition: forward.h:36
static int Alive
Definition: minimal.cc:17
static void myFree(void *const buf)
Definition: minimal.cc:90
FREE * memFreeBufFunc(size_t)
Definition: minimal.cc:96
void memFreeString(size_t, void *memory)
Definition: minimal.cc:72
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:60
void * memReallocBuf(void *const oldBuf, const size_t netSize, size_t *const grossSize)
Definition: minimal.cc:53
void * memAllocRigid(const size_t netSize)
Definition: minimal.cc:78
void memFreeBuf(size_t, void *const buf)
Definition: minimal.cc:84
void * memAllocString(const size_t netSize, size_t *const grossSize)
Definition: minimal.cc:66
#define xfree
#define xmalloc
void * xcalloc(size_t n, size_t sz)
Definition: xalloc.cc:71
void * xrealloc(void *s, size_t sz)
Definition: xalloc.cc:126

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors