24#ifndef MALLOC_ALLOCATOR_INCLUDED
25#define MALLOC_ALLOCATOR_INCLUDED
62template <
class T =
void *>
90 assert(
m_key == other.psi_key());
94 if (
n == 0)
return nullptr;
95 if (
n >
max_size())
throw std::bad_alloc();
99 if (
p ==
nullptr)
throw std::bad_alloc();
105 template <
class U,
class... Args>
107 assert(
p !=
nullptr);
109 ::new ((
void *)
p)
U(std::forward<Args>(args)...);
116 assert(
p !=
nullptr);
125 return std::numeric_limits<size_t>::max() /
sizeof(T);
Malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: malloc_allocator.h:63
size_t size_type
Definition: malloc_allocator.h:69
void construct(U *p, Args &&... args)
Definition: malloc_allocator.h:106
size_type max_size() const
Definition: malloc_allocator.h:124
PSI_memory_key psi_key() const
Definition: malloc_allocator.h:133
T & reference
Definition: malloc_allocator.h:75
const_pointer address(const_reference r) const
Definition: malloc_allocator.h:79
T value_type
Definition: malloc_allocator.h:68
pointer address(reference r) const
Definition: malloc_allocator.h:78
void deallocate(pointer p, size_type)
Definition: malloc_allocator.h:103
pointer allocate(size_type n, const_pointer hint=nullptr)
Definition: malloc_allocator.h:93
Malloc_allocator(const Malloc_allocator< U > &other)
Definition: malloc_allocator.h:84
void destroy(pointer p)
Definition: malloc_allocator.h:115
PSI_memory_key m_key
Definition: malloc_allocator.h:65
Malloc_allocator & operator=(const Malloc_allocator< U > &other)
Definition: malloc_allocator.h:88
const T * const_pointer
Definition: malloc_allocator.h:73
T * pointer
Definition: malloc_allocator.h:72
ptrdiff_t difference_type
Definition: malloc_allocator.h:70
Malloc_allocator(PSI_memory_key key)
Definition: malloc_allocator.h:81
const T & const_reference
Definition: malloc_allocator.h:76
const char * p
Definition: ctype-mb.cc:1237
#define U
Definition: ctype-tis620.cc:75
#define ME_FATALERROR
Definition: my_sys.h:152
#define MY_WME
Definition: my_sys.h:123
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
bool operator==(const Malloc_allocator< T > &a1, const Malloc_allocator< T > &a2)
Definition: malloc_allocator.h:137
bool operator!=(const Malloc_allocator< T > &a1, const Malloc_allocator< T > &a2)
Definition: malloc_allocator.h:142
#define MYF(v)
Definition: my_inttypes.h:97
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
Common header for many mysys elements.
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Definition: malloc_allocator.h:129
Malloc_allocator< U > other
Definition: malloc_allocator.h:130
int n
Definition: xcom_base.cc:509