MySQL 8.4.2
Source Code Documentation
Component_malloc_allocator< T > Class Template Reference

Component_malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free. More...

#include <component_malloc_allocator.h>

Classes

struct  rebind
 

Public Types

typedef T value_type
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 

Public Member Functions

pointer address (reference r) const
 
const_pointer address (const_reference r) const
 
 Component_malloc_allocator (PSI_memory_key key)
 
template<class U >
 Component_malloc_allocator (const Component_malloc_allocator< U > &other)
 
template<class U >
Component_malloc_allocatoroperator= (const Component_malloc_allocator< U > &other)
 
pointer allocate (size_type n, const_pointer=nullptr)
 
void deallocate (pointer p, size_type)
 
template<class U , class... Args>
void construct (U *p, Args &&... args)
 
void destroy (pointer p)
 
size_type max_size () const
 
PSI_memory_key psi_key () const
 

Private Attributes

PSI_memory_key m_key
 

Detailed Description

template<class T = void *>
class Component_malloc_allocator< T >

Component_malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.

This allows for P_S instrumentation of memory allocation done internally by STL container classes in components.

Example usage: vector<int, Component_malloc_allocator<int>> v((Component_malloc_allocator<int>(PSI_NOT_INSTRUMENTED)));

If the type is complicated, you can just write Component_malloc_allocator<>(psi_key) as a shorthand for Component_malloc_allocator<My_complicated_type>(psi_key), as all Component_malloc_allocator instances are implicitly convertible to each other and there is a default template parameter.

Note
allocate() throws std::bad_alloc() similarly to the default STL memory allocator. This is necessary - STL functions which allocates memory expects it. Otherwise these functions will try to use the memory, leading to segfaults if memory allocation was not successful.
This allocator cannot be used for std::basic_string with RHEL 6/7 because of this bug: https://bugzilla.redhat.com/show_bug.cgi?id=1546704 "Define _GLIBCXX_USE_CXX11_ABI gets ignored by gcc in devtoolset-7"

Member Typedef Documentation

◆ const_pointer

template<class T = void *>
typedef const T* Component_malloc_allocator< T >::const_pointer

◆ const_reference

template<class T = void *>
typedef const T& Component_malloc_allocator< T >::const_reference

◆ difference_type

template<class T = void *>
typedef ptrdiff_t Component_malloc_allocator< T >::difference_type

◆ pointer

template<class T = void *>
typedef T* Component_malloc_allocator< T >::pointer

◆ reference

template<class T = void *>
typedef T& Component_malloc_allocator< T >::reference

◆ size_type

template<class T = void *>
typedef size_t Component_malloc_allocator< T >::size_type

◆ value_type

template<class T = void *>
typedef T Component_malloc_allocator< T >::value_type

Constructor & Destructor Documentation

◆ Component_malloc_allocator() [1/2]

template<class T = void *>
Component_malloc_allocator< T >::Component_malloc_allocator ( PSI_memory_key  key)
inlineexplicit

◆ Component_malloc_allocator() [2/2]

template<class T = void *>
template<class U >
Component_malloc_allocator< T >::Component_malloc_allocator ( const Component_malloc_allocator< U > &  other)
inline

Member Function Documentation

◆ address() [1/2]

template<class T = void *>
const_pointer Component_malloc_allocator< T >::address ( const_reference  r) const
inline

◆ address() [2/2]

template<class T = void *>
pointer Component_malloc_allocator< T >::address ( reference  r) const
inline

◆ allocate()

template<class T = void *>
pointer Component_malloc_allocator< T >::allocate ( size_type  n,
const_pointer  = nullptr 
)
inline

◆ construct()

template<class T = void *>
template<class U , class... Args>
void Component_malloc_allocator< T >::construct ( U p,
Args &&...  args 
)
inline

◆ deallocate()

template<class T = void *>
void Component_malloc_allocator< T >::deallocate ( pointer  p,
size_type   
)
inline

◆ destroy()

template<class T = void *>
void Component_malloc_allocator< T >::destroy ( pointer  p)
inline

◆ max_size()

template<class T = void *>
size_type Component_malloc_allocator< T >::max_size ( ) const
inline

◆ operator=()

template<class T = void *>
template<class U >
Component_malloc_allocator & Component_malloc_allocator< T >::operator= ( const Component_malloc_allocator< U > &  other)
inline

◆ psi_key()

template<class T = void *>
PSI_memory_key Component_malloc_allocator< T >::psi_key ( ) const
inline

Member Data Documentation

◆ m_key

template<class T = void *>
PSI_memory_key Component_malloc_allocator< T >::m_key
private

The documentation for this class was generated from the following file: