24#ifndef COMPONENT_MALLOC_ALLOCATOR_INCLUDED
25#define COMPONENT_MALLOC_ALLOCATOR_INCLUDED
62template <
class T =
void *>
92 assert(
m_key == other.psi_key());
96 if (
n == 0)
return nullptr;
97 if (
n >
max_size())
throw std::bad_alloc();
100 if (
p ==
nullptr)
throw std::bad_alloc();
106 template <
class U,
class... Args>
108 assert(
p !=
nullptr);
110 ::new ((
void *)
p)
U(std::forward<Args>(args)...);
117 assert(
p !=
nullptr);
126 return std::numeric_limits<size_t>::max() /
sizeof(T);
Component_malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: component_malloc_allocator.h:63
void destroy(pointer p)
Definition: component_malloc_allocator.h:116
PSI_memory_key psi_key() const
Definition: component_malloc_allocator.h:134
const_pointer address(const_reference r) const
Definition: component_malloc_allocator.h:79
void deallocate(pointer p, size_type)
Definition: component_malloc_allocator.h:104
pointer allocate(size_type n, const_pointer=nullptr)
Definition: component_malloc_allocator.h:95
T value_type
Definition: component_malloc_allocator.h:68
void construct(U *p, Args &&...args)
Definition: component_malloc_allocator.h:107
T & reference
Definition: component_malloc_allocator.h:75
size_t size_type
Definition: component_malloc_allocator.h:69
ptrdiff_t difference_type
Definition: component_malloc_allocator.h:70
const T & const_reference
Definition: component_malloc_allocator.h:76
PSI_memory_key m_key
Definition: component_malloc_allocator.h:65
Component_malloc_allocator(PSI_memory_key key)
Definition: component_malloc_allocator.h:81
Component_malloc_allocator(const Component_malloc_allocator< U > &other)
Definition: component_malloc_allocator.h:84
Component_malloc_allocator & operator=(const Component_malloc_allocator< U > &other)
Definition: component_malloc_allocator.h:90
const T * const_pointer
Definition: component_malloc_allocator.h:73
pointer address(reference r) const
Definition: component_malloc_allocator.h:78
T * pointer
Definition: component_malloc_allocator.h:72
size_type max_size() const
Definition: component_malloc_allocator.h:125
bool operator!=(const Component_malloc_allocator< T > &a1, const Component_malloc_allocator< T > &a2)
Definition: component_malloc_allocator.h:144
bool operator==(const Component_malloc_allocator< T > &a1, const Component_malloc_allocator< T > &a2)
Definition: component_malloc_allocator.h:138
const char * p
Definition: ctype-mb.cc:1225
#define U
Definition: ctype-tis620.cc:74
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
Header for compiler-dependent features.
void * my_malloc(PSI_memory_key key, size_t size, int flags)
Allocates size bytes of memory.
Definition: my_memory.cc:57
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Definition: component_malloc_allocator.h:130
Component_malloc_allocator< U > other
Definition: component_malloc_allocator.h:131
int n
Definition: xcom_base.cc:509