MySQL 9.1.0
Source Code Documentation
Scoped_heap Struct Reference

Heap wrapper that destroys the heap instance when it goes out of scope. More...

#include <mem0mem.h>

Classes

struct  mem_heap_free_functor
 A functor with no state to be used for mem_heap destruction. More...
 

Public Types

using Type = mem_heap_t
 

Public Member Functions

 Scoped_heap ()
 Default constructor. More...
 
 Scoped_heap (size_t n, ut::Location location) noexcept
 Constructs heap with a free space of specified size. More...
 
 ~Scoped_heap ()=default
 Destructor. More...
 
void create (size_t n, ut::Location location) noexcept
 Create the heap, it must not already be created. More...
 
bool is_null () const noexcept
 Check if the memory heap has been created. More...
 
Typeget () noexcept
 
void reset (Type *p)
 Set the pointer to p. More...
 
void clear () noexcept
 Empty the heap. More...
 
void * alloc (size_t n_bytes) noexcept
 Allocate memory in the heap. More...
 

Private Types

using Ptr = std::unique_ptr< Type, mem_heap_free_functor >
 

Private Member Functions

 Scoped_heap (Scoped_heap &&)=delete
 
 Scoped_heap (const Scoped_heap &)=delete
 
Scoped_heapoperator= (Scoped_heap &&)=delete
 
Scoped_heapoperator= (const Scoped_heap &)=delete
 

Private Attributes

Ptr m_ptr {}
 Heap to use. More...
 

Detailed Description

Heap wrapper that destroys the heap instance when it goes out of scope.

Member Typedef Documentation

◆ Ptr

using Scoped_heap::Ptr = std::unique_ptr<Type, mem_heap_free_functor>
private

◆ Type

Constructor & Destructor Documentation

◆ Scoped_heap() [1/4]

Scoped_heap::Scoped_heap ( )
inline

Default constructor.

◆ Scoped_heap() [2/4]

Scoped_heap::Scoped_heap ( size_t  n,
ut::Location  location 
)
inlinenoexcept

Constructs heap with a free space of specified size.

Parameters
[in]nInitial size of the heap to allocate.
[in]locationLocation from where called.

◆ ~Scoped_heap()

Scoped_heap::~Scoped_heap ( )
default

Destructor.

◆ Scoped_heap() [3/4]

Scoped_heap::Scoped_heap ( Scoped_heap &&  )
privatedelete

◆ Scoped_heap() [4/4]

Scoped_heap::Scoped_heap ( const Scoped_heap )
privatedelete

Member Function Documentation

◆ alloc()

void * Scoped_heap::alloc ( size_t  n_bytes)
inlinenoexcept

Allocate memory in the heap.

Parameters
[in]n_bytesNumber of bytes to allocate.
Returns
pointer to allocated memory.

◆ clear()

void Scoped_heap::clear ( )
inlinenoexcept

Empty the heap.

◆ create()

void Scoped_heap::create ( size_t  n,
ut::Location  location 
)
inlinenoexcept

Create the heap, it must not already be created.

Parameters
[in]nInitial size of the heap to allocate.
[in]locationLocation from where called.

◆ get()

Type * Scoped_heap::get ( )
inlinenoexcept
Returns
the heap pointer.

◆ is_null()

bool Scoped_heap::is_null ( ) const
inlinenoexcept

Check if the memory heap has been created.

Returns
true if memory heap is not created, false if memory heap is created.

◆ operator=() [1/2]

Scoped_heap & Scoped_heap::operator= ( const Scoped_heap )
privatedelete

◆ operator=() [2/2]

Scoped_heap & Scoped_heap::operator= ( Scoped_heap &&  )
privatedelete

◆ reset()

void Scoped_heap::reset ( Type p)
inline

Set the pointer to p.

Parameters
[in]pNew pointer value.

Member Data Documentation

◆ m_ptr

Ptr Scoped_heap::m_ptr {}
private

Heap to use.


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