PoolingAllocator.h
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#ifndef SQUID_MEM_POOLINGALLOCATOR_H
10#define SQUID_MEM_POOLINGALLOCATOR_H
11
12#include "mem/forward.h"
13
14#include <utility>
15
17template <class Value>
19{
20public:
21 /* STL Allocator API */
22 using value_type = Value;
23 PoolingAllocator() noexcept {}
24 template <class Other> PoolingAllocator(const PoolingAllocator<Other> &) noexcept {}
25 value_type *allocate(std::size_t n) { return static_cast<value_type*>(memAllocRigid(n*sizeof(value_type))); }
26 void deallocate(value_type *vp, std::size_t n) noexcept { memFreeRigid(vp, n*sizeof(value_type)); }
27
28 template <class OtherValue>
29 struct rebind {
31 };
32
33 template<class U, class ... Args> void construct(U *p, Args && ... args) { new((void *)p) U(std::forward<Args>(args)...); }
34 template<typename OtherValue> void destroy(OtherValue *p) { p->~OtherValue(); }
35};
36
37template <class L, class R>
38inline bool
40{
41 return true;
42}
43
44template <class L, class R>
45inline bool
47{
48 return !(l == r);
49}
50
51#endif /* SQUID_MEM_POOLINGALLOCATOR_H */
52
bool operator!=(const PoolingAllocator< L > &l, const PoolingAllocator< R > &r) noexcept
bool operator==(const PoolingAllocator< L > &, const PoolingAllocator< R > &) noexcept
STL Allocator that uses Squid memory pools for memory management.
void destroy(OtherValue *p)
void construct(U *p, Args &&... args)
void deallocate(value_type *vp, std::size_t n) noexcept
PoolingAllocator(const PoolingAllocator< Other > &) noexcept
PoolingAllocator() noexcept
value_type * allocate(std::size_t n)
void * memAllocRigid(size_t net_size)
Definition: minimal.cc:78
void memFreeRigid(void *, size_t net_size)
Definition: minimal.cc:84
PoolingAllocator< OtherValue > other
int const char size_t
Definition: stub_liblog.cc:83

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors